From: | Albe Laurenz <laurenz(dot)albe(at)wien(dot)gv(dot)at> |
---|---|
To: | "'Ramesh T *EXTERN*'" <rameshparnanditech(at)gmail(dot)com>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: to pg |
Date: | 2015-09-25 13:56:56 |
Message-ID: | A737B7A37273E048B164557ADEF4A58B50FAF8F0@ntex2010i.host.magwien.gv.at |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Ramesh T wrote:
> CREATE UNIQUE INDEX idx_load_pick ON pick (case picked when picked='y' then load_id else null end );
>
> how can i convert case expressed to postgres..above it is oracle.
CREATE TABLE pick (picked char(1), load_id integer);
CREATE FUNCTION picked_loadid(character, integer) RETURNS integer
IMMUTABLE STRICT LANGUAGE sql AS
$$SELECT CASE WHEN $1 = 'y' THEN $2 ELSE NULL END$$;
CREATE INDEX idx_load_pick ON pick (picked_loadid(picked, load_id));
*but*
It will only work with queries like:
SELECT * FROM pick WHERE picked_loadid(picked, load_id) IS NOT NULL;
Yours,
Laurenz Albe
From | Date | Subject | |
---|---|---|---|
Next Message | Francisco Reyes | 2015-09-25 14:20:44 | Re: Dropped connections with pg_basebackup |
Previous Message | Ladislav Lenart | 2015-09-25 13:44:20 | Re: to pg |