FAQ
Edit report at http://pear.php.net/bugs/bug.php?id=16867&edit=1

ID: 16867
Updated by: php@gartneriet.dk
Reported By: php at gartneriet dot dk
Summary: PostgreSQL errors when using Native sequences
Status: Open
Type: Documentation Problem
Package: DB_DataObject
Package Version: 1.8.12
PHP Version: Irrelevant
Roadmap Versions:
New Comment:

You're right - i missed that my sequences where named
<tablename>_<fieldname>_seq.

It seems like I could then make a sequenceKey()-method in the table's
DataObject, to return the name of the sequence to use. However, the
docblock for DB_DataObject::sequenceKey() say that its a private method,
and the manual page doesn't say anything about this method.
However, the docblock also say: 'Override this to return ....'


Previous Comments:
------------------------------------------------------------------------

[2009-12-03 00:30:57] alan_k

-Type: Bug
+Type: Documentation Problem
It's not documented (could probably do with a note in the manual
somwhere)
, but you need to create your tables like this.

CREATE TABLE reservations (
id integer DEFAULT nextval('reservations_seq'::text) NOT NULL

sequence name is tablename with _seq at the end.

------------------------------------------------------------------------

[2009-12-02 21:29:32] madsliejensen

Added #patch bug:16867;patch:pgsql-sequence-patch;revision:1259789372;.

------------------------------------------------------------------------

[2009-12-02 21:28:05] madsliejensen

Description:
------------
When a tables primary key is a native sequence, for postgreSQL,
DB_DataObject does a 'SELECT currval(<sequence-name>)' to get the key to
use when inserting a new row. (In DataObject.php line 1084)

However, you cannot call currval() without first having called
nextval(<sequence-name>), thus, there will be an error from postgreSQL.

The correct thing to do would be 'SELECT nextval(<sequence-name>)'
instead.

------------------------------------------------------------------------

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 2 of 3 | next ›
Discussion Overview
grouppear-bugs @
categoriesphp
postedDec 2, '09 at 11:31p
activeDec 3, '09 at 7:56a
posts3
users2
websitepear.php.net

2 users in discussion

Alan: 2 posts Php: 1 post

People

Translate

site design / logo © 2021 Grokbase