Received: from localhost (maia-2.hub.org [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id D5D6B9FB3FB for ; Mon, 29 Jan 2007 20:15:11 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-new, port 10024) with ESMTP id 31735-01 for ; Mon, 29 Jan 2007 20:15:04 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.116.145.2]) by postgresql.org (Postfix) with ESMTP id 497629FB3F8 for ; Mon, 29 Jan 2007 20:15:08 -0400 (AST) Received: by floppy.pyrenet.fr (Postfix, from userid 106) id 1CDC730E32; Tue, 30 Jan 2007 01:15:07 +0100 (MET) From: Tobias Thierer X-Newsgroups: pgsql.interfaces.jdbc Subject: Re: escape string for pgsql (using jdbc/java)? Date: Tue, 30 Jan 2007 13:15:08 +1300 Organization: Hub.Org Networking Services Lines: 39 Message-ID: References: <45BD294D.5040002@opencloud.com> <2473B100-9BC0-42F1-9CE5-02DF41E49569@fastcrypt.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@news.hub.org User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.9) Gecko/20061211 SeaMonkey/1.0.7 In-Reply-To: <2473B100-9BC0-42F1-9CE5-02DF41E49569@fastcrypt.com> To: pgsql-jdbc@postgresql.org X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.001 tagged_above=0 required=5 tests=BAYES_50 X-Spam-Level: X-Archive-Number: 200701/183 X-Sequence-Number: 16548 Hi, Dave Cramer wrote: >> I'm not so worried about the performance. But if I have a column of >> type SERIAL in my table, then I can retrieve the generated value using: [...] > You could if that worked in postgresql but getGeneratedKeys does not > currently work Yes, I was actually just about to post a follow-up to my previous message because I just found out that pgsql doesn't support this. >> whereas it is not clear to me how this works with a prepared >> statement. Strangely, PreparedStatement extends Statement, so >> PreparedStatement still has the executeUpdate(String,int) method - but >> it is not clear to me whether this method will throw the previously >> prepared statement away or what. >> >> Is there any easy way to retrieve the generated value for the SERIAL >> column when using a prepared statement? >> > Yes, if it worked it would work with prepared statements. Yes, I just found that out too. But given that pgsql doesn't allow me to immediately retrieve the value of the autogenerated key, how can I (or can't I!?)? If I made a SELECT MAX(id) statement right afterwards then I couldn't be sure that that is the id just generated, because due to concurrency someone else may have just submitted an entry too, right? How are these things done in pgsql? Tobias