views:

357

answers:

2

I am using Adodb and Postgresql. When I insert a row, it increments the ID field using SERIAL.

Is it possible to return the newly created ID number right after the insert?

+1  A: 
$db->Insert_ID();
Nirmal
+1  A: 

Treat your INSERT the same as a SELECT and use RETURNING in your INSERT-query:

INSERT INTO foo (bar) VALUES('Doe') RETURNING id;

Fetch the result and you're done. Works since version 8.2

Frank Heikens