如何在 Gupta SQL Base 中获取最后插入的记录 ID

How to get last inserted record Id in Gupta SQL Base

我是 Gupta Sql 基地的新手。我想知道如何在 Gupta 中获取最后插入的记录 SQL

如果您使用 SYSDBSequence.NextVal 生成您的主键,无论是在 Insert stmt 中,还是在 Insert 之前,您都可以在 Insert 之后通过选择 [Primary Key] = SYSDBSequence.Currval 例如 Select Name from Patient Where Patient_Id = SYSDBSequence.Currval

或者,如果您的主键列已定义为 AUTO_INCREMENT ,您可以在插入后使用 MAX( [Primary Key ] ) select 返回它,例如 Select Name from Patient Where Patient_Id = (Select MAX( Patient_Id) from Patient )

或者,如果上述 none,则向 return 写入一个插入触发器,或者将 PK 存储在 table 中,这样您将始终拥有最新的PK记录给你。

您可能想在 enter link description here or there is much archived information at enter link description here

加入 Gupta 用户论坛