Re: Multiple Statement result set problem with PreparedStatements

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 02:03:45
Message-ID: 42D5C801.4060006@opencloud.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Lenard, Rohan (Rohan) wrote:
> What I'm trying to do is do 2 inserts and get the resultant key values
> from the 2 inserts - i.e. effectively the row indexes (there are
> separate sequences for the pkey for each table, so the currval() gives
> the key of the insert for that table.
>
> This SQL works fine from any command line interface to the DB - giving
> the expected results.
>

> However through the JDBC driver, I don't get any results with a select
> involving the 2 seqs, but if I choose just one I do !!.

That is weird.

I will try to find time to put together a selfcontained testcase later
on (you could speed this up by sending me one :)

> BTW - The followup analysis below is flawed.
>
> With this SQL the driver always returns false for the execute() thus
> taking the getMoreResults() path & there are never results for the
> INSERT (at least not easily obtainable via the API in a generic way).

Sorry -- not thinking there :)

What I'd expect to see is this sequence:

execute() returns false (no resultset for this result)
getUpdateCount() returns 1 (1 row inserted)
getMoreResults() returns false (no resultset for this result)
getUpdateCount() returns 1 (1 row inserted)
getMoreResults() returns true (resultset present)
getResultSet() returns an appropriate resultset for the SELECT
getMoreResults() returns false (no resultset for this result)
getUpdateCount() returns -1 (no more results)

Your code seems to be expecting something different..

-O

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Lenard, Rohan (Rohan) 2005-07-14 02:05:36 Re: Multiple Statement result set problem with PreparedStatements ?
Previous Message Lenard, Rohan (Rohan) 2005-07-14 01:45:24 Re: Multiple Statement result set problem with PreparedStatements ?