i want pass bunch of Update queries in the form of array to pl/pgsql
function as parameter and there i need to execute those sql
update queries. is it possible.please help me to get out of this.
Asked
Active
Viewed 798 times
0
-
do you want someting like this http://stackoverflow.com/questions/1637825/how-to-use-an-in-clause-in-ibatis – farmer1992 Jan 28 '13 at 06:55
-
no sir not like that i want to pass array as argument to function.the array contains group of update queries and i want to execute those queries by iterating that array in that function – raju Jan 28 '13 at 07:02
-
and that function also having other parameters – raju Jan 28 '13 at 07:06
-
Have a look at this: [Passing Arrays as Arguments](http://joaopribs.wordpress.com/2012/04/11/passing-arrays-as-arguments-in-plpgsql-functions/). You can pass full statements in, iterate over the array, and execute them with EXECUTE IMMEDIATE. – Brian.D.Myers Jan 31 '13 at 00:37
1 Answers
0
Passing the array in is not to hard. Generate a quoted csv list of the queries, surround by {}
braces and pass that in as a bound parameter. For example....
{"UPDATE foo SET bar = 1 where baz = 1","alter table foo add foobar int","drop database critical_prodiction_database"}
Then pass it in as a text[]
parameter.

Chris Travers
- 25,424
- 6
- 65
- 182