Re: Select nextval problem
| От | Ron St.Pierre |
|---|---|
| Тема | Re: Select nextval problem |
| Дата | |
| Msg-id | 8G7F9.61884$ea.1090269@news2.calgary.shaw.ca обсуждение исходный текст |
| Ответ на | Re: Select nextval problem (SZUCS Gábor <surrano@mailbox.hu>) |
| Список | 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@syscor.com
В списке pgsql-general по дате отправления: