From: | mallah(at)trade-india(dot)com |
---|---|
To: | "Hunter, Ray" <rhunter(at)enterasys(dot)com> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Sequences |
Date: | 2002-02-11 15:19:17 |
Message-ID: | 3C67E0F5.1E213068@trade-india.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Further to Brunos' suggestion,
if you require to use the same id for insertion in other tables
(slaves) you should
assign the value to a variable and use that value for inserting
in other referencing tables eg
$id = $dbh -> selectrow_array("select nextval('seq_name')"); (# perl
specific)
insert into users ( "user_id", "user_fname", "user_lname", "user_email"
)
values ( $id , 'Ray', 'Hunter', 'rhunter(at)enterasys(dot)com' );
insert into user_details ( "user_id", ..... other details .... )
values ( $id , .... other details .... );
"Hunter, Ray" wrote:
>
>
> I have various sequences in my database set up for ids. My question
> is: How can I get the current value of the sequence without creating
> a session and using the currval function?
>
> I would like to take the current value of the sequence and use it for
> a value in an insert statement.
>
> Example:
>
> insert into users ( "user_id", "user_fname", "user_lname",
> "user_email" )
> values ( 'current sequence', 'Ray', 'Hunter',
> 'rhunter(at)enterasys(dot)com' );
>
> Thanks,
>
> Ray Hunter
> Firmware Engineer
>
> ENTERASYS NETWORKS
>
> Phone: 801 887-9888
> Fax: 801 972-5789
> Email: rhunter(at)enterasys(dot)com
> www: www.enterasys.com
From | Date | Subject | |
---|---|---|---|
Next Message | mallah | 2002-02-11 15:38:57 | Re: Sequences |
Previous Message | T Conti | 2002-02-11 15:15:37 | Join Statements |