Skip Menu |
 

This queue is for tickets about the DBIx-LazyMethod CPAN distribution.

Report information
The Basics
Id: 6767
Status: open
Priority: 0/
Queue: DBIx-LazyMethod

People
Owner: Nobody in particular
Requestors: jonasbn [...] io.dk
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



To: bugs-dbix-lazymethod [...] rt.cpan.org
From: Jonas B.Nielsen <jonasbn [...] io.dk>
Subject: Use of OID for Postgres is misleading
Date: Mon, 28 Jun 2004 13:16:54 +0200
Download (untitled) / with headers
text/plain 1.2k
Hi Casper, I am currently working on a database implemented using Postgresql. In order to find out how to get a autoincremented id out (serial in Postgresql) I looked at your code, because I could remember you listed this as a possible return value. As far as I can tell you are using the OID for for this for DBD::Pg. The OID is NOT the autoincremented value of a specified id, but a internal reference number, it is unique but it is not the number which should be returned in this case, hence it is not equal to the autoincremented value. Please see the definition of the OID here: http://www.postgresql.org/docs/faqs/FAQ.html#4.16 It seems that DBI since 1.38 have specified a method called: last_insert_id, this might be what we need? From DBI POD: -- Returns a value 'identifying' the row just inserted, if possible. Typically this would be a value assigned by the database server to a column with an auto_increment or serial type. Returns undef if the driver does not support the method or can't determine the value. -- Unfortunately it is driver specific and does not seem to be implemented in DBD::Pg currently: Please see: http://rt.cpan.org/NoAuth/Bug.html?id=3803 I do not know about DBD::MySQL jonasbn
Download (untitled) / with headers
text/plain 216b
[jonasbn@io.dk - Mon Jun 28 07:16:55 2004]: This link might provide a work-around until the DBD:: drivers are syncronized... http://gborg.postgresql.org/pipermail/dbdpg-general/2004-February/000810.html jonasbn
Download (untitled) / with headers
text/plain 217b
[JONASBN - Mon Jun 28 07:27:03 2004]: The provided solution does not seem to mention it, but since Postgresql does not seem to implement the lastval as MySQL, you have to subtract 1 from the returned ID. jonasbn


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.