Calling a stored procedure with array parameters - Mailing list pgsql-jdbc

From peter mcgregor
Subject Calling a stored procedure with array parameters
Date
Msg-id 439D1398-BB35-11D7-A096-003065E5EDC4@advso.co.nz
Whole thread Raw
List pgsql-jdbc
Hi,

I am trying to call the following stored procedure


rooms=# select sp_copyRoomItems1('{9,2}','{1}');

 sp_copyroomitems1

-------------------

                 2

(1 row)



from jdbc


using the following test code


<fixed>            ArrayList fromEquipments =
<color><param>7676,0F0F,5050</param>new</color> ArrayList();

            <color><param>7676,0F0F,5050</param>for</color>
(<color><param>7676,0F0F,5050</param>int</color>
i=<color><param>0000,0000,FFFF</param>0</color>; i <<
selectedFromEquipmentItems.count(); i++) {

                Equipment         fromEquipment         =
(Equipment)selectedFromEquipmentItems.objectAtIndex(i);


fromEquipments.add(Library.getPrimaryKey(fromEquipment));

            }

            CallableStatement cstmt =
connection.prepareCall(<color><param>8989,1313,1515</param>"{ call
sp_CopyRoomItems1( ? , ? ) } "</color>);


cstmt.setObject(<color><param>0000,0000,FFFF</param>1</color>,fromEquipments);


cstmt.setObject(<color><param>0000,0000,FFFF</param>2</color>,fromEquipments);


However, I get an error when this is run


 The table for java.util.ArrayList is not in the database. Contact the
DBA, as the database is in an inconsistent state.


The code that I have seen on the net is all about returning arrays
from stored procedures.


Is it possible to pass an array to a stored procedure?


TIA


Peter McGregor</fixed>
Hi,
I am trying to call the following stored procedure

rooms=# select sp_copyRoomItems1('{9,2}','{1}');
  sp_copyroomitems1
-------------------
                  2
(1 row)


from jdbc

using the following test code

             ArrayList fromEquipments = new ArrayList();
             for (int i=0; i < selectedFromEquipmentItems.count(); i++) {
                 Equipment         fromEquipment         =
(Equipment)selectedFromEquipmentItems.objectAtIndex(i);

fromEquipments.add(Library.getPrimaryKey(fromEquipment));
             }
             CallableStatement cstmt = connection.prepareCall("{ call
sp_CopyRoomItems1( ? , ? ) } ");
             cstmt.setObject(1,fromEquipments);
             cstmt.setObject(2,fromEquipments);

However, I get an error when this is run

  The table for java.util.ArrayList is not in the database. Contact the
DBA, as the database is in an inconsistent state.

The code that I have seen on the net is all about returning arrays from
stored procedures.

Is it possible to pass an array to a stored procedure?

TIA

Peter McGregor

pgsql-jdbc by date:

Previous
From: Oliver Jowett
Date:
Subject: Re: Prepared Statements
Next
From: Tony Grant
Date:
Subject: Re: Problems with Spanish Chars