ROWID columns
Informix®
When creating a table, Informix automatically adds a
ROWID
integer column (applies to non-fragmented tables only).
The ROWID
column is auto-filled with a unique number and can be used like a
primary key to access a given row.
Informix ROWID
usage was a
common practice in the early days of Informix
4GL programming. Today it is recommended to define all your database tables with a
PRIMARY KEY
to uniquely identify rows.
With Informix, the sqlca.sqlerrd[6]
register contains the ROWID
of the last row affected by an INSERT
,
UPDATE
or DELETE
statement.
ORACLE
Oracle® supports ROWID
columns, but the data type is different from Informix
ROWIDs: Oracle rowids are
CHAR(18)
.
AAAA8mAALAAAAQkAAA
Since Oracle rowids are physical
addresses, they cannot be used as permanent row identifiers: After a DELETE
, an
INSERT
statement might reuse the physical place of the deleted row, to store the
new row.
The Oracle Call Level (OCI) provides functions to get the rowid of the last row related to an
INSERT
, UPDATE
, DELETE
statement, ora
FETCH
of a cursor declared with a SELECT FOR UPDATE
.
Solution
If your Genero BDL application uses Informix rowid columns, review the program logic to use the primary keys when available, or use Oracle rowids.
ROWID
values must be
changed to CHAR(18)
.Informix INTEGER
rowids fit in a
CHAR(18)
variable. If you adapt the code to use CHAR(18)
rowids,
the code will still work with Informix database.
sqlca.sqlerrd[6]
must be reviewed, because this register can not
contain the rowid of the last affected row. However, after an INSERT
,
UPDATE
or DELETE
statement, or after a FETCH
of a
cursor declared with a SELECT FOR UPDATE
, the sqlca.sqlerrm
register is filled with the character extended (base 64) representation of the rowid of the last
affected or fetched row.The sqlca.sqlerrm register only contains a single rowid, even if
multiple rows were affected by the INSERT
, UPDATE
or
DELETE
statement.
ROWID
", the translation can be controlled
with the following FGLPROFILE
entry:dbi.database.dsname.ifxemul.rowid = {
true |
false }
For more details see IBM Informix emulation parameters in FGLPROFILE.