Re: Serial key

From: Dave Cramer <pg(at)fastcrypt(dot)com>
To: Bhushan Bhangale <bbhangale(at)Lastminute(dot)com>
Cc: "pgsql-jdbc(at)postgresql(dot)org" <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: Serial key
Date: 2004-02-13 18:53:14
Message-ID: 1076698394.6785.43.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Yes,

the easiest and best way to do this is to append select
curval('sequencename') to your inserts

ie insert into foo .....; select curval('sequence');

and then use the execute command

Dave
On Fri, 2004-02-13 at 12:23, Bhushan Bhangale wrote:
> Hi,
>
> I have a table in which the primary key is of type SERIAL. I insert a record
> and then I want the generated id because of this, so that I can use the id
> to insert records in child table.
>
> I know about a solution in which generate a id before hand and then use the
> id to insert in table and also in child tables.
>
> The other stuff which I read in JDK 1.4 is of getGeneratedKeys().
>
> The problem is I have to use JDK 1.3.1.
>
> Is there any solution for this problem?
>
> Thanks
> Bhushan
>
> ________________________________________________________________________
> This e-mail has been scanned for all viruses by Star Internet. The
> service is powered by MessageLabs. For more information on a proactive
> anti-virus service working around the clock, around the globe, visit:
> http://www.star.net.uk
> ________________________________________________________________________
>
> ---------------------------(end of broadcast)---------------------------
> TIP 8: explain analyze is your friend
>
--
Dave Cramer
519 939 0336
ICQ # 14675561

In response to

  • Serial key at 2004-02-13 17:23:03 from Bhushan Bhangale

Browse pgsql-jdbc by date

  From Date Subject
Next Message John Sidney-Woollett 2004-02-13 18:56:29 Re: Serial key
Previous Message Kris Jurka 2004-02-13 18:39:44 Re: Serial key