Re: Get last id in postgresql
| From: | Ramil G. Sagum | Date: | Tue, 17 Jun 2003 02:46:02 +0000 |
| Subject: | Re: Get last id in postgresql | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-28660@lists.php.net to get a copy of this message | ||
pg_last_oid returns the last object id (an id used in the system
catalogs) and not the ID/index of the row.
if you need to get the last ID, you need to execute another select or
write a pl/sql function.
On Tue, 2003-06-17 at 10:13, Norma Ramirez - TECNOSOFT wrote:
> Hi all,
> I´m starting with posgresql and i trying to use pg_last_oid to get the last id in a insert
> query, but this function returns me a big number
> like 21318 and bigger, but the table just have 3 or 4 records. Could some one help? Any ideas?
> This is the script i´m using
> $insert = "insert into test(name) values('myname')";
> $test = pg_exec($insert);
> echo $id = pg_last_oid($test);
>
> Norma Ramirez
> norma.ramirez@tecnosoft.com.co
>