From: | "Ron St(dot)Pierre" <rstpierre(at)syscor(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Select nextval problem |
Date: | 2002-11-27 17:55:16 |
Message-ID: | 8G7F9.61884$ea.1090269@news2.calgary.shaw.ca |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
I use something similar (watch where nextval/currval are used):
SELECT nextval('prodid_seq');
INSERT INTO product VALUES (currval('prodid_seq'),'...',...,'');
SELECT * FROM product WHERE prodid = (SELECT
nextval('prodid_seq'));
But there's probably a better way....
SZUCS Gábor wrote:
>>SELECT nextval('prodid_seq') as id;
>>
>>INSERT INTO product VALUES (nextval('prodid_seq'),'...',...,'');
>>
>>OK up to this point.
>>
>>Now how do I SELECT back the record I just inserted.
>>
>>SELECT * FROM product WHERE prodid = id;
>>ERROR: Attribute 'id' not found
>>
>>OK, I'm not very good at SQL yet. How do you put the sequence number in
>>a place holder, then do the insert, and finally retrieve the record you
>>just inserted by matching the prodid with the number in the place holder.
>>
>>
>
>
>
--
Ron St.Pierre
Syscor R&D
tel: 250-361-1681
email: rstpierre(at)syscor(dot)com
From | Date | Subject | |
---|---|---|---|
Next Message | Al Bean | 2002-11-27 17:58:28 | versions |
Previous Message | Loeke | 2002-11-27 17:44:42 | postgres linux server + windows/linux clients (ip) + ldap authentification + secure |