Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DB2 Query Batch?

 
Fred Welland
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using DB2 Type4 "Universal" driver against DB2 v8 (on aix)

I'd like to do something like this:


buf.append("DECLARE GLOBAL TEMPORARY TABLE .....;");
buf.append("update temp table....;');
buf.append("DELETE from temp table where xxx;");
buf.append("select * from temp table;");

bool = stmt.execute(buf.toString());

//process update counts and results sets with
//stmt.getUpdateCount(), stmt.getMoreResults(), stmt.getResultSet()...

DB2 complains about this some token missing on the first line. I have done this under oracle.

So does DB2 support this kind of thing? If so, how? Links to an example would be great.
[ April 04, 2005: Message edited by: Bear Bibeault ]
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Fred,
Does db2 support submitting multiple SQL statements in one shot? I think it doesn't, but I'm not positive. A simple way to find out is to run "select * from table; select * from table;" That way you can isolate the multiple statements from the temp table and updates.
 
Fred Welland
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
tried that already. Didn't work strange syntax errors. so I am assuming that either I don't have the correct syntax (i tried lots of permutations) or not supported.

Digging around IBM.com didn't lead me one way or the other.

I was hoping someone here might now...

i am beginning to think it is not supported.....
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Fred,
The syntax is simple. It's either statements separated by semicolons or not supported at all. I agree that if it didn't work, it isn't supported.

You can batch somewhat by doing the first three of those statements in a JDBC batch (only non-select queries supported) and then doing the select.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic