PLS-00103:尝试用序列递增值时遇到符号DECLARE/EOF



我正在处理一个过程,该过程将声明一个变量,从递增的过程中获取值,并将该值与其他参数一起插入表中。我以为我已经全部解决了,但后来我被PLS-00103击中了:遭遇符号";DECLARE";和遭遇符号";文件末尾";。我觉得我很亲近,所以任何帮助都将不胜感激!非常感谢。

create or replace procedure Order_Create(date_order string, cust_id char, total float, employ_id number)
is
DECLARE NewKey;
BEGIN
NewKey := order_auto_inc.nextval;
UPDATE Progressive_Keys set Order_Limit = NewKey;
insert into ORDERS VALUES (Progressive_Keys.Order_Limit, to_date(date_order, 'yyyy-mm-dd'), cust_id, total, employ_id);
commit;
END;

删除存储过程中不需要的declare(如手册中所述(。

变量声明需要一个数据类型。

由于参数order_date应该是一个日期,因此应该使用该类型来声明它。

不能在使用表progressive_keys的语句之外访问列order_limit,因此还需要在insert语句中使用该变量。

总是在INSERT语句中列出目标列也是一种很好的编码实践(注意,我刚刚为orders表发明了一些列名,您必须调整它们以反映表中的真实名称(

create or replace procedure Order_Create(date_order date, cust_id varchar, total float, employ_id number)
is
NewKey number;
BEGIN
NewKey := order_auto_inc.nextval;
UPDATE Progressive_Keys set Order_Limit = NewKey;
insert into ORDERS (some_key, order_date, customer_id, total, employee_id)
VALUES (newkey, date_order, cust_id, total, employ_id);
commit;
END;

UPDATE看起来有点奇怪,因为它将更新thableprogressive_keys中的所有行,而不仅仅是一行。

最新更新