admin

在pl / sql块中声明变量

sql

我正在尝试按照该指南创建pl/sql块,并且在上出现ORA-00922:missing或invalid选项SET orderNumberSEQ...。我究竟做错了什么?

declare
orderNumberSEQ number(5);
userid varchar(20);

begin
insert into bs_orders (userid, ono, timepurchased)
values('lilith', orderNum_seq.NEXTVAL,(SELECT current_timestamp FROM dual));

SET orderNumberSEQ := orderNum_seq.CURRVAL;

SELECT userid FROM bs_orders
where ono = orderNumberSEQ;
end;
/

阅读 216

收藏
2021-06-07

共1个答案

admin

您无需使用SET。只是

SELECT orderNum_seq.CURRVAL INTO orderNumberSEQ FROM DUAL;

会成功的 或者,如果您使用oracle11

orderNumberSEQ := orderNum_seq.CURRVAL;
2021-06-07