我是Gupta Sql Base的新手。我想知道如何在Gupta SQL中获取最后插入的记录
答案 0 :(得分:0)
如果您使用SYSDBSequence.NextVal生成主键,可以在Insert stmt内,也可以在Insert之前生成主键,然后您可以在Insert by Choose Where [Primary Key] = SYSDBSequence.Currval之后立即检索它。
Select Name from Patient Where Patient_Id = SYSDBSequence.Currval
或者,如果您的主键列已被定义为AUTO_INCREMENT,您可以在使用MAX([主键])插入后选择它,例如
Select Name from Patient Where Patient_Id = (Select MAX( Patient_Id) from Patient )
或者,如果不是上述任何一种,那么写一个Insert Trigger来返回它,或者将PK存储在一个表中,这样你就可以随时记录最新的PK。
您可以在enter link description here加入Gupta用户论坛,或者enter link description here
上有大量存档信息