pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
PLSQL Question regarding multiple inserts
2+ messages / 2 participants
[nested] [flat]

* PLSQL Question regarding multiple inserts
@ 2004-02-25 03:56 Humble Geek <humblegeek@rogers.com>
  2004-03-01 04:17 ` Re: PLSQL Question regarding multiple inserts V i s h a l Kashyap @ [Sai Hertz And Control Systems] <sank89@sancharnet.in>
  0 siblings, 1 reply; 2+ messages in thread

From: Humble Geek @ 2004-02-25 03:56 UTC (permalink / raw)
  To: pgsql-sql

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





^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: PLSQL Question regarding multiple inserts
  2004-02-25 03:56 PLSQL Question regarding multiple inserts Humble Geek <humblegeek@rogers.com>
@ 2004-03-01 04:17 ` V i s h a l Kashyap @ [Sai Hertz And Control Systems] <sank89@sancharnet.in>
  0 siblings, 0 replies; 2+ messages in thread

From: V i s h a l Kashyap @ [Sai Hertz And Control Systems] @ 2004-03-01 04:17 UTC (permalink / raw)
  To: Humble Geek <humblegeek@rogers.com>; +Cc: pgsql-sql

Dear Humble Geek ,

>-- 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 
>  
>
Nop,
If  the insert and later on

currval('someSeq') is called inside the same function

currval will only return the current value that has been effected by the 
first  insert  made.



-- 
Best Regards,
Vishal Kashyap
Director / Lead Developer,
Sai Hertz And Control Systems Pvt Ltd,
http://saihertz.rediffblogs.com
Jabber IM: vishalkashyap@jabber.org
ICQ :      264360076
Yahoo  IM: mailforvishal@yahoo.com
-----------------------------------------------
You yourself, as much as anybody in the entire
universe, deserve your love and affection.
- Buddha
---------------
pgsql=# select marital_status from vishals_life;

marital_status
------------------
Single not looking

1 Row(s) affected

                    ___
                   //\\\
                  ( 0_0 )
----------------o0o-----o0o---------------------




^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2004-03-01 04:17 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-02-25 03:56 PLSQL Question regarding multiple inserts Humble Geek <humblegeek@rogers.com>
2004-03-01 04:17 ` V i s h a l Kashyap @ [Sai Hertz And Control Systems] <sank89@sancharnet.in>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox