Re: [GENERAL] unique index with bool

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Re: [GENERAL] unique index with bool

Stuart Bishop
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

[hidden email] wrote:
> CREATE UNIQUE INDEX name on table(param1,param2);
>
> How to create such unique index when param2 is bool type, and this param2 should be accepted only in case of true ?
>
> I tried: CREATE UNIQUE INDEX name on table(param1,(param2 = 'true'));
> but it's not working.

CREATE UNIQUE INDEX foo ON table(param1, (NULLIF(param2, false)))



- --
Stuart Bishop <[hidden email]>
http://www.stuartbishop.net/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)

iD8DBQFCk/6KAfqZj7rGN0oRAvZ+AJwLWDd8FQe5nBjFDv7ariZ8o8rwLgCfRTdy
BP2yMApbjMDdpDqetUQnX3A=
=k5zA
-----END PGP SIGNATURE-----

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

               http://www.postgresql.org/docs/faq