开发者

Php:ingres equivalent of mysql_insert_id()

开发者 https://www.devze.com 2023-03-27 00:33 出处:网络
I\'ve to make some PHP interaction with 开发者_JAVA技巧an Ingres database. I need to get the ID of the last entry I inserted in the database.

I've to make some PHP interaction with 开发者_JAVA技巧an Ingres database. I need to get the ID of the last entry I inserted in the database.

How should I proceed? I'm not an ingres expert, but I suppose there is also auto-incremented ID/Sequences/...?

Thank you very much


The last_identity() function will give you the last generated sequence number for a table, e.g.:

SELECT last_identity() FROM t1

From what I understand the sequence number needs to be created, using CREATE TABLE using the following syntax:

colname integer generated always as identity

e.g.:

CREATE TABLE t1 ( 
    idx integer generated always as identity,
    sometext varchar(100) not null
)

See http://community.ingres.com/wiki/Using_Ingres_Identity_Columns for some additional notes on using identity columns.

0

精彩评论

暂无评论...
验证码 换一张
取 消