D&C Lug - Home Page
Devon & Cornwall Linux Users' Group

[ Date Index ][ Thread Index ]
[ <= Previous by date / thread ] [ Next by date / thread => ]

RE: [LUG] postgresql inserts



You can do:
SELECT currval('sequence_name') as cv;
The default sequence names for serial are, IIRC: <table_name>_<column_name>_seq
Alternativley you can do a nextval('seq_name') then insert that value (which is the way I prefer).
Cheers,
- Stuart
 
-----Original Message-----
From: chris [mailto:chris@xxxxxxxxxxxxxxxxxx]
Sent: 14 April 2003 16:24
To: list@xxxxxxxxxxxx
Subject: RE: [LUG] postgresql inserts

Does postgres have stored procedures or similar?
-----Original Message-----
From: owner-list@xxxxxxxxxxxx [mailto:owner-list@xxxxxxxxxxxx]On Behalf Of Robert Nowik
Sent: 14 April 2003 16:05
To: List@xxxxxxxxxxxx
Subject: [LUG] postgresql inserts

Hi,
Not really a linux specific problem, but in postgreSQL i am trying to have an INSERT statement, that has a serial as the only unique identifier. This serial is not set by myself (postgres handles this) but as this is the only unqiue identifier, i need to return it as I do the insert. Any suggestions?
 
 
Cheers
 
Rob Nowik


DISCLAIMER:The information in this message is confidential and may be legally privileged. It is intended solely for the addressee. Access to this message by anyone else is unauthorised. If you are not the intended recipient, any disclosure, copying, or distribution of the message, or any action or omission taken by you in reliance on it, is prohibited and may be unlawful. Please immediately contact the sender if you have received this message in error. Thank you.




Lynx friendly