这是我的存储过程,我正在尝试获取最后插入的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;
答案 0 :(得分:1)
在插入查询之后,只需使用此:
select current_identity_value() FROM DUMMY;
它将返回最新的插入值