这是我的存储过程,我正在尝试获取最后一个插入的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;
它将返回最新插入的值
关于database - 如何获取SAP HANA数据库中最后插入的记录标识符?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/52166632/