Update table using array

From: "Mehrotra, Abhinav (GE Healthcare)" <Abhinav(dot)Mehrotra(at)ge(dot)com>
To: <pgsql-novice(at)postgresql(dot)org>
Subject: Update table using array
Date: 2010-09-28 06:34:36
Message-ID: 516FCC77ADD26141AF6F0EA95E0AA56406FBD339@BANMLVEM04.e2k.ad.ge.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice


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

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2010-09-28 06:42:52 Re: srpm odd spec file?
Previous Message Lukasz Brodziak 2010-09-28 05:03:23 PostgreSQL 8.4 won't start