这是我正在尝试运行的程序。它插入两个表table1
和一个关联表table2
。
create or replace procedure Insert_Row (summary IN VARCHAR2
description IN VARCHAR2, status IN NUMBER,
date_submitted IN DATE, last_updated IN DATE,
owner_id IN NUMBER, reporter_id IN NUMBER,
foo IN VARCHAR2, bar IN VARCHAR2,
first_assignee IN NUMBER)
is
l_cur_id number;
begin
insert into table1
(summary, description, status, date_submitted,
last_updated, owner_id, reporter_id,
foo, bar)
values( :summary, :description, :status,
to_date(:date_submitted,'YYYY-MM-DD'),
to_date(:last_updated,'YYYY-MM-DD'), :owner_id,
:reporter_id, :foo, :bar)
returning action_id into l_cur_id;
insert into table2(action_id, assignee_id)
values(l_cur_id,:test);
commit;
end;"
没有参数,查询工作正常。即,如果我删除所有:somethings
值并对值进行硬编码,那么它在我运行时运行时不会出现错误exec Insert_Row;
使用参数(带有:somethings
),有错误:
show errors procedure Insert_Row;
Errors: check compiler log
2/4 PLS-00103: Encountered the symbol "DESCRIPTION" when expecting one of the following:
:= . ) , @ % default character
The symbol "," was substituted for "DESCRIPTION" to continue.
14/13 PLS-00049: bad bind variable 'SUMMARY'
14/23 PLS-00049: bad bind variable 'DESCRIPTION'
14/37 PLS-00049: bad bind variable 'STATUS'
15/21 PLS-00049: bad bind variable 'DATE_SUBMITTED'
16/21 PLS-00049: bad bind variable 'LAST_UPDATED'
16/50 PLS-00049: bad bind variable 'OWNER_ID'
17/13 PLS-00049: bad bind variable 'REPORTER_ID'
17/27 PLS-00049: bad bind variable 'FOO'
17/33 PLS-00049: bad bind variable 'BAR'
20/21 PLS-00049: bad bind variable 'TEST'
我究竟做错了什么?
编辑
@ron tornambe 的解决方案后查询是:
create or replace procedure Insert_Row (summary IN VARCHAR2,
description IN VARCHAR2, status IN NUMBER,
date_submitted IN DATE, last_updated IN DATE,
owner_id IN NUMBER, reporter_id IN NUMBER,
foo IN VARCHAR2, bar IN VARCHAR2,
first_assignee IN NUMBER)
is
l_cur_id number;
begin
insert into table1
(summary, description, status, date_submitted,
last_updated, owner_id, reporter_id,
foo, bar)
values( :summary, :description, :status,
to_date(:date_submitted,'YYYY-MM-DD'),
to_date(:last_updated,'YYYY-MM-DD'), :owner_id,
:reporter_id, :foo, :bar)
returning action_id into l_cur_id;
insert into table2(action_id, assignee_id)
values(l_cur_id,:test);
commit;
end;"
此修改后的错误是:
14/13 PLS-00049: bad bind variable 'SUMMARY'
14/23 PLS-00049: bad bind variable 'DESCRIPTION'
14/37 PLS-00049: bad bind variable 'STATUS'
15/21 PLS-00049: bad bind variable 'DATE_SUBMITTED'
16/21 PLS-00049: bad bind variable 'LAST_UPDATED'
16/50 PLS-00049: bad bind variable 'OWNER_ID'
17/13 PLS-00049: bad bind variable 'REPORTER_ID'
17/27 PLS-00049: bad bind variable 'FOO'
17/33 PLS-00049: bad bind variable 'BAR'
20/21 PLS-00049: bad bind variable 'TEST'
非常感谢。