BUG #1640: Using JDBC, multiple statements do not return results if select follows insert, delete or update

From: "Kevin Self" <kself(at)micromedia(dot)ca>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #1640: Using JDBC, multiple statements do not return results if select follows insert, delete or update
Date: 2005-04-29 18:52:51
Message-ID: 20050429185251.54805F0B04@svr2.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs


The following bug has been logged online:

Bug reference: 1640
Logged by: Kevin Self
Email address: kself(at)micromedia(dot)ca
PostgreSQL version: 8.0.2
Operating system: Windows XP
Description: Using JDBC, multiple statements do not return results if
select follows insert,delete or update
Details:

When attempting to perform a multi-statement command through the JDBC
Statement.execute() or the Statement.executeQuery() function, the database
does not return any result set if the select statement follows an insert,
update or delete. This ability is required for atomic record inserts for
auto-generated keys that must be returned to the caller, since postgreSQL
does not support RETURN_GENERATED_KEYS as an option, and calling the
sequence ahead of time to obtain the value is not possible.

Pre-conditions:
Assuming a database called 'test'
Assuming a user called 'test' with a password 'test'.
create a table as follows:

create table test (a serial primary key,b int);

Example:
public static void main(String[] args) throws Exception
{
try
{
Class.forName("org.postgresql.Driver");
Connection lc =
DriverManager.getConnection("jdbc:postgresql://localhost/test","test","test"
);
PreparedStatement stmt = lc.prepareStatement("insert into test(b)
values(100);select currval('test_a_seq');");

if(!stmt.execute()){System.out.println("NO RESULTS!");}
else {System.out.println("RESULTS!");}
lc.close();
}
catch(Exception e)
{
System.out.println(e.toString());
}
}

Expectd Results:
RESULTS!

Actual results:
NO RESULTS!

Notes:
This used to work in the previous version of PostgreSQL (7.x).

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Jim C. Nasby 2005-04-29 23:09:08 Re: looks like apple fixed /etc/rc
Previous Message PABLO 2005-04-29 18:47:18 BUG #1639: Problema re-instalacion