开发者

Php:ingres equivalent of mysql_insert_id()

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜