any better idea? so far I can only rely on option 2.
Thanks.
How about loading from cursor?
Cheers,
Manoj Sutar
Hi Yonghang,
You can combine these 2 methods with batch queries as well:
http://publib.boulder.ibm.com/infocenter/db2luw/v9r7/topic/com.ibm.db2.luw.apdv.java.doc/src/tpc/imjcc_tjvjcbqu.html
Sincerely,
Mark B.
just curious, is there anybody from IBM lab can show us whether it's possible to "declare cursor on JDBC ResultSet" or c/c++ alternatives.
I'm not from the IBM lab but I can tell you that it's not possible :)
In CLI (but not in JDBC) you can use column-wise array input:
http://publib.boulder.ibm.com/infocenter/db2luw/v9r7/topic/com.ibm.db2.luw.apdv.cli.doc/doc/t0007268.html
If you're able to save the contents of your ResultSet to some csv file
on the db2 server, you can load it with IMPORT/LOAD utilities via
ADMIN_CMD routine.
You can create a procedure which takes an ARRAYs of scalar values as
input (you need to create type first).
Then do the INSERT within that procedure.
Something like this:
CREATE TYPE varchar_arr AS VARCHAR(4000) ARRAY[];
CREATE TYPE int_arr AS INTEGER ARRAY[];
--#SET TERMINATOR @
CREATE OR REPLACE PROCEDURE insert_t(pk int_arr, val varchar_arr)
BEGIN
INSERT INTO t(pk, val) SELECT * FROM UNNEST(pk, val) AS T(pk, val);
END
@
--#SET TERMINATOR ;
JDBC can pass arrays to a CALL.
I think (?) in 9.7.4 you can also pass an array of rows.
Cheers
Serge
--
Serge Rielau
SQL Architect DB2 for LUW, IBM Toronto Lab
Blog: tinyurl.com/SQLTips4DB2
Wiki: tinyurl.com/Oracle2DB2Wiki
Twitter: srielau