Home > Archive > PostgreSQL JDBC > July 2005 > Re: Multiple Statement result set problem with PreparedStatements









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: Multiple Statement result set problem with PreparedStatements
Oliver Jowett

2005-07-14, 3:24 am

Lenard, Rohan (Rohan) wrote:

> final PreparedStatement stmt = conn. createPreparedStatem
ent("
> INSERT INTO foo ( a, b ) VALUES ( ?, ? );
> INSERT INTO bar ( foo_fkey, c ) VALUES ( ?, currval('foo_seq'::t
ext) );
> SELECT currval('bar_seq'::t
ext), currval('foo_seq'::t
ext);");
>
> stmt.setString(1, "A");
> stmt.setString(2, "B");
> stmt.setString(3, "C");
>
> boolean result = stmt.execute();
> if (result) {
> processRS(stmt.getResultSet());
> }


That should handle the first INSERT.

> else {
> if (getMoreResults()) {
> processRS(stmt.getResultSet()); // only gets called with 1 element
> SELECTED.
> }
> }


That should handle the second INSERT.

You do not appear to be handling the results of the SELECT at all.

Your testcase is not very clear about what you're trying to do and the
incorrect behaviour you see :/

-O

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com