From: | "Nikolay Samokhvalov" <samokhvalov(at)gmail(dot)com> |
---|---|
To: | Adam <adam(at)spatialsystems(dot)org> |
Cc: | "Postgres general mailing list" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Getting Primary Key Value After Insert |
Date: | 2006-07-10 20:42:16 |
Message-ID: | e431ff4c0607101342j3c3afe51q789fd951dd582f61@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
As a alternative way, you may forget about sequence name and create
rule for you table - simple rule that will make 'SELECT idColumnName'
on every INSERT action.
After trying several approaches I've chosen this way in my projects.
It's better way if you have some framework (R2O layer or smth).
On 7/9/06, Adam <adam(at)spatialsystems(dot)org> wrote:
> I'm inserting data into two tables, the second table has a forigen key that
> points to the primary key of the first table.
>
> After I insert a row into the first table, I need to take the primary key
> value created in "SERIAL" column and store it so I can insert it as the
> forigen key value on the second table.
>
> What is the best way to get the value of the primary key ( SERIAL data
> type ) of the row I inserted?
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: Don't 'kill -9' the postmaster
>
--
Best regards,
Nikolay
From | Date | Subject | |
---|---|---|---|
Next Message | Mark Morgan Lloyd | 2006-07-10 21:20:57 | Re: Procedural language functions across servers |
Previous Message | Vivek Khera | 2006-07-10 19:52:41 | Re: US Telephone Number Type |