Skip site navigation (1) Skip section navigation (2)

Re: sequence value of the record just inserted / DBI

From: "Greg Sabino Mullane" <greg(at)turnstep(dot)com>
To: pgsql-admin(at)postgresql(dot)org
Subject: Re: sequence value of the record just inserted / DBI
Date: 2004-04-15 01:55:59
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-admin
Hash: SHA1
> Perl's DBI has the following function.
> $rv = $dbh->last_insert_id($catalog, $schema, $table, $field);
> "Returns a value 'identifying' the row just inserted, if possible."
> I wonder what this $catalog is in this context. It's supposed to be
> metadata, and CREATE USER has CATALOG|NOCATALOG option, but what would be
> $catalog value for a user table in this context?
DBD::Pg does not support last_insert_id yet. It's so new, that none
of the DBDs support it yet. When it is implemented in DBD::Pg, the catalog
option will be ignored, as PostgreSQL has no catalog concept (nor do most
other RDBM systems). You will notice that most of the other DBI functions
have the same $catalog, $schema, $table ... design. In that context,
catalog is meant as a higher-level than the schema: you can think of it
as a collection of schemas.
Keep in mind the last_insert_id() function is mostly meant as a portability
helper: unless you are porting your script to other databases, just
use nextval (number 2 in your other email) which is perfectly safe.
- --
Greg Sabino Mullane greg(at)turnstep(dot)com
PGP Key: 0x14964AC8 200404142155

In response to

pgsql-admin by date

Next:From: Greg Sabino MullaneDate: 2004-04-15 02:01:18
Subject: Re: sequence value of the record just inserted.
Previous:From: Jeremy BuchmannDate: 2004-04-14 19:22:45
Subject: Re: sequence value of the record just inserted / DBI

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group