Skip site navigation (1) Skip section navigation (2)

PLSQL Question regarding multiple inserts

From: "Humble Geek" <humblegeek(at)rogers(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: PLSQL Question regarding multiple inserts
Date: 2004-02-25 04:11:37
Message-ID: ZfV_b.60$Yf.1@twister01.bloor.is.net.cable.rogers.com (view raw or flat)
Thread:
Lists: pgsql-general
Hi all. Quick and perhaps silly question, but...

I am using Pg 7.3. I am writing a function using pgplsql. This function will
perform multiple inserts. Let's say two of the inserts are as follows:

-- id is primary key
insert into users (id, username) values (nextval('someSeq'),'somename');

-- id is also a PK
insert into log (id, uid, message) values (nextval('someOtherSeq'),XXX,'New
Account');

Assume XXX is the id from the first insert. How do I get that number? Not
currval('someSeq') -  'cause someone else may have performed an insert - but
the id for that specific insert.

Thanks,

HG

PS: Sorry for the cross-post...



Responses

pgsql-general by date

Next:From: Tom LaneDate: 2004-02-25 04:15:26
Subject: Re: [HACKERS] select statement against pg_stats returns inconsistent data
Previous:From: Christopher Kings-LynneDate: 2004-02-25 04:07:20
Subject: Re: [HACKERS] select statement against pg_stats returns

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group