From: | Lukasz Brodziak <lukasz(dot)brodziak(at)gmail(dot)com> |
---|---|
To: | "Mehrotra, Abhinav (GE Healthcare)" <Abhinav(dot)Mehrotra(at)ge(dot)com>, pgsql-novice(at)postgresql(dot)org |
Subject: | Re: Update table using array |
Date: | 2010-09-28 06:50:05 |
Message-ID: | AANLkTin_4MDdhhWO1=x9agdAbMYTVud63fy9sq1q+7L+@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
Hi,
If it is a single-row array I would go with temporary table and a
cursor with FOR UPDATE. Check here for details:
http://www.postgresql.org/docs/current/static/sql-declare.html
2010/9/28 Mehrotra, Abhinav (GE Healthcare) <Abhinav(dot)Mehrotra(at)ge(dot)com>:
>
> Hi,
>
> I want to update a column matching all elements of array. But,I don't
> want to iterate over all elements of array.
> Basically, I am writing a procedure for
>
> update tx set delete_flag=''true'' where tx_id in (10,20,);
>
> Something like below procedure(which is not currect)
>
> CREATE OR REPLACE FUNCTION t1(bigint[]) RETURNS text AS '
> DECLARE
> cnt INTEGER;
> ret text;BEGIN
> update tx set delete_flag=''true'' where tx_id in ($1);
> return ret;
> end;
> '
> language 'plpgsql';
>
>
> Is there anyway to update the table for all elements of array in one go?
>
>
> - Abhinav
>
> --
> Sent via pgsql-novice mailing list (pgsql-novice(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-novice
>
--
Łukasz Brodziak
II MU Bioinformatyka
From | Date | Subject | |
---|---|---|---|
Next Message | Devrim GÜNDÜZ | 2010-09-28 07:12:28 | Re: srpm odd spec file? |
Previous Message | Tom Lane | 2010-09-28 06:42:52 | Re: srpm odd spec file? |