Re: ERROR: 22P02: invalid input syntax for integer [message #4948 is a reply to message #4946] |
Fri, 28 August 2015 14:29 |
rafs
Messages: 69 Registered: May 2015
|
Member |
|
|
I think my field 'uid' is already a serial data type. This link shows that the serial is just an integer with a default of nextval('idps_uid_seq') function set to the named SEQUENCE.
http://www.postgresql.org/docs/9.2/static/datatype-numeric.h tml, Section 8.1.4).
Also, I tested this insert from command line using psql and it does insert the (DEFAULT) next value into my 'uid' field for this record:
INSERT INTO idps (idp_type, idp_id, idp_calc, idp_status) VALUES ('idp', 1, 'idp1', 0)
In my case, the field, 'uid', is not the PK, it is a candidate key with UNIQUE constraint. (The PK is a compound key from idp_type, idp_id.)
Is the framework using $pkey variable to mean only PUBLIC KEY only, or does it include UNIQUE KEYs as well?
Quoting you from the link you mention (above), you say, $pkey, but my field is not a PK...
Quote:
With PostgreSQL the same can be achieved with:
$query = "SELECT currval('" .$tablename .'_' .$pkey ."_seq')";
$result = pg_query($link, $query) or trigger_error($this, E_USER_ERROR);
$id = pg_fetch_result($result, 0, 0);
This is because the SERIAL keyword makes use of a counter with the default name of <tablename>_<fieldname>_seq. This can be accessed using the currval() and nextval() functions.
Could this be the issue?
[Updated on: Fri, 28 August 2015 15:41] Report message to a moderator
|
|
|