Hello everyone i'm trying to understand how PostgreSQL is behaving against Powerbuilder 2022 R3, in particular the auto-increment columns.
I've create a new postgres DB with a simple table called "test"; Reading the documentation i see that there are two ways to handle identity columns:
Support for auto-increment column
PostgreSQL supports the auto-increment column with the following two methods:
-
Method 1: GetIdentity='Select currval(''GEN_&TableName'')'
-
Method 2: GetIdentity='Select currval(''&TableName._&ColumnName._seq')'
Method 2 uses the serial to create the auto-increment column.
These methods require that the sequence name follows the name conversions specified by GetIdentity in pbodb.ini, for example, gen_TableName, TableName_ColumnName_seq. If the sequence name is not in the required format, the identity value cannot be obtained automatically.
i've added the identity column as "serial" data type from postgresql PGadmin4 and it created automatically the sequence script.
i've also enabled the PBODB.INI [PGSQL_SYNTAX] this way:
AddMembers='GRANT &GroupID TO &UserID'
DeleteMembers='REVOKE &GroupID FROM &UserID'
;GetIdentity='Select currval(''GEN_&TableName'')'
GetIdentity='Select currval(''&TableName._&ColumnName._seq')'
; Alternative technique if table has identity or serial column
GetCatalogIdentity='SELECT a.attname as name FROM pg_catalog.pg_class as c Left JOIN pg_catalog.pg_attrdef as p ON c.oid = p.adrelid LEFT JOIN
I've created a simple pb app with a datawindow, but when i try to insert a new record on it, the identity column does not populate automatically like it does on SQL Anywhere. The id is generated correctly cos if i do a retrieve after the update it shows correctly.
I guess i missing something, but any help would be appreciated
i'll add some screeshots showing how i configured the table
tia,
simone
Thank for that update & the great news!
Regards ...Chris
as solution you described, now its all ok.
thanks Simone!