gpt4 book ai didi

hana - 如何获取 SAP HANA 数据库中最后插入的记录标识符?

转载 作者:搜寻专家 更新时间:2023-10-30 22:25:58 32 4
gpt4 key购买 nike

这是我的存储过程,我试图获取最后插入的 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;

最佳答案

在插入查询后使用这个:

从虚拟中选择 current_identity_value();

它将返回最新插入的值

关于hana - 如何获取 SAP HANA 数据库中最后插入的记录标识符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52166632/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com