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:
> 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

---------------------------(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