Calling a stored procedure with array parameters

Поиск
Список
Период
Сортировка
Искать

Calling a stored procedure with array parameters

От:
peter mcgregor <pdm@advso.co.nz>
Дата:
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 =
7676,0F0F,5050new ArrayList(); 

            7676,0F0F,5050for
(7676,0F0F,5050int
i=0000,0000,FFFF0; i <<
selectedFromEquipmentItems.count(); i++) {

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

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

            }

            CallableStatement cstmt =
connection.prepareCall(8989,1313,1515"{ call
sp_CopyRoomItems1( ? , ? ) } ");

           
cstmt.setObject(0000,0000,FFFF1,fromEquipments);

           
cstmt.setObject(0000,0000,FFFF2,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
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
FAQ