logo       

Sponsor
FREE Network Mapping Tool for Microsoft® Office Visio® Professional 2007
Don't map your network by hand - let LANsurveyor Exx press for Microsoft Visio Professional 2007 automatically create network diagrams for you!

Re: JDBC and fetching the OID of an insert: msg#00160

db.postgresql.jdbc

Subject: Re: JDBC and fetching the OID of an insert

Hi Daryl,
Hi all,

> I asked this question a little while back too. :) I'm sure it is a
> question that comes up quite often.
> The simple answer that I got is to do:
>
> SELECT nextval(columnName);
> INSERT INTO tableName (columnName) VALUES ([result of first query]);
>
> through JDBC calls. If the insert fails, nothing is lost. No real
> need for a transaction here.

Well, so I can't use OIDs but only SEQUENCES, at least with JDBC.

> I cannot speak on whether or not getGeneratedKeys() is
> supported/implemented in the JDBC driver.

> public ResultSet getGeneratedKeys()
as well as corresponding methods like
> public int executeUpdate(String sql, String columnNames[])
are new in JDBC3.

They are not yet implemented in the PostgreSQL JDBC driver (I had a look at
the code in CVS).

To all the JDBC developers: do you think it would be possible to implement
these?
I would offer my help.

What I am thinking of is:
- do the insert
- get the OID of the inserted row (should be possible inside the driver,
right?)
- fetch the values of those fields that where requested

At least this would not require any help from the backend. On the other hand
it would still leave the question open how to decide what is considered a
generated key. I will have a look at the JDBC specs.

Best Regards,
Michael




---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo@xxxxxxxxxxxxxx)






Only community members can participate in forum threads. You must Register or log in to contribute.

<Prev in Thread] Current Thread [Next in Thread>
Sponsor
FREE Network Mapping Tool for Microsoft® OfficeVisio Professional 2007
Don't map your network by hand - let LANsurveyor Express for Microsoft Visio Professional 2007
automatically create network diagrams for you!
Google Custom Search

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe

Navigation

Home | sitemap | advertise | OSDir is an inevitable website. super tiny logo