[英]How to get the last inserted record identifier in SAP HANA database?
这是我的存储过程,我正在尝试获取最后插入的DepartmentId
。 没有MAX(DepartmentId)
不寻找触发器和任何解决方案
CREATE PROCEDURE "BPPRA_CUSTOM_APP"."AddUpdateMaster_Department"(IN DepartmentId BIGINT,Department nvarchar(100),Description nvarchar(100),UserId int)
LANGUAGE SQLSCRIPT
--READS SQL DATA
AS
BEGIN
if DepartmentId>0
then
update "BPPRA_CUSTOM_APP"."Master_Department" set "Department"=Department,"Description"=Description ,"ModifiedUserId"=UserId,"ModifiedDate"=CURRENT_TIMESTAMP
where "DepartmentId"= :DepartmentId;
select DepartmentId FROM DUMMY;
ELSE
insert into "BPPRA_CUSTOM_APP"."Master_Department" ("Department","Description","CreatedUserId","CreatedDate")
values(Department,Description,UserId,CURRENT_TIMESTAMP);
END IF;
END;
在插入查询之后,只需使用以下命令:
select current_identity_value() FROM DUMMY;
它将返回最新的插入值
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.