Yes, they are called sequences in postgres. Create table tablename (id serial, .... ) This creates a sequence named tablename_id_seq You can then do a select on Select next('tablename_id_seq') Which will give you the next sequence and increment it Dave -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of stefan Sent: July 16, 2001 1:06 PM To: [EMAIL PROTECTED] Subject: [GENERAL] Getting key value with an insert and using it in another. Hi: I need to be able to grab a key value generated by the server so that I can use it with other inserts within the context of a transaction. In a nut shell, I have an order table and an order details table. When an order is saved, it has to go into both the order table and the order detail tables where the order details records require the key value created in the order table. SQL server had a function to do this (@@identity) does PostGresSql have anything? Thanks, Stefan ---------------------------(end of broadcast)--------------------------- TIP 2: you can get off all lists at once with the unregister command (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED]) ---------------------------(end of broadcast)--------------------------- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your message can get through to the mailing list cleanly