how to pass an array to the plpgsql function from Java Code
Started by Sandeep Kumar Jakkarajuabout 19 years ago2 messagesgeneral
how to pass an array to the plpgsql function from Java Code ??
say from a JDBC preparedStatement ....
Example :-
create or replace function test( x integer[] ) returns integer as
$BODY$
BEGIN
RETURN x[0];
END ;
language 'plpgsql'
JDBC CODE :-
int [] ar = {1,2,3};
PreparedStament pre= connection.prepareStatement( " select test(?) ");
pre.setArray(1,ar};
Re: how to pass an array to the plpgsql function from Java Code
On Mar 4, 11:34 am, sandeepkumar.jakkar...@gmail.com ("Sandeep Kumar
Jakkaraju") wrote:
how to pass an array to the plpgsql function from Java Code ??
If nothing else, you could use the ARRAY[] constructor:
int [] ar = {1,2,3};
PreparedStament pre= connection.prepareStatement( " select
test(ARRAY[?,?,?]) ");
pre.setArray(1,ar[0]);
pre.setArray(2,ar[1]);
pre.setArray(3,ar[2]);