Value of sequence last inserted

From: bryan(at)flyingiranch(dot)com
To: pgsql-novice(at)postgresql(dot)org
Subject: Value of sequence last inserted
Date: 2003-03-10 14:57:17
Message-ID: H00000660001d19c.1047308237.mule.flyingiranch.com@MHS
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

I have a sequence that I am using on a field that I am using for the ID
of an item in a table. After an insert to that table, I need to insert
into two other tables using the same ID - does the initial insert
somehow return the value of the sequence that was used? I know it may
not be reliable to do, say "SELECT MAX ID FROM"..., so how can I assure
that I have the right ID for my other inserts? Should I just do the set
of inserts as a transaction?

Thanks,

Bryan

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Josh Berkus 2003-03-10 15:07:37 Re: get the oid
Previous Message Tom Lane 2003-03-10 14:55:15 Re: select