From: | Oliver Jowett <oliver(at)opencloud(dot)com> |
---|---|
To: | "Lenard, Rohan (Rohan)" <rlenard(at)avaya(dot)com> |
Cc: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | Re: Multiple Statement result set problem with PreparedStatements |
Date: | 2005-07-14 01:40:19 |
Message-ID: | 42D5C283.8010707@opencloud.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
Lenard, Rohan (Rohan) wrote:
> final PreparedStatement stmt = conn.createPreparedStatement("
> INSERT INTO foo ( a, b ) VALUES ( ?, ? );
> INSERT INTO bar ( foo_fkey, c ) VALUES ( ?, currval('foo_seq'::text) );
> SELECT currval('bar_seq'::text), currval('foo_seq'::text);");
>
> 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
From | Date | Subject | |
---|---|---|---|
Next Message | Lenard, Rohan (Rohan) | 2005-07-14 01:45:24 | Re: Multiple Statement result set problem with PreparedStatements ? |
Previous Message | Lenard, Rohan (Rohan) | 2005-07-14 00:50:44 | Multiple Statement result set problem with PreparedStatements ? |