我创建了一个SP,如下所示: 目的是向xyz传递2个参数。 SP xyz将从表t1读取记录并存储在游标中。 反过来,xyz将在循环中调用另一个SP sp2,并将记录存储在游标中。 当我试图在TOAD中运行它时,我收到了错误
ORA-06550: line 2, column 3:
PLS-00201: identifier 'abc.xyz' must be declared
ORA-06550: line 2, column 3:
PL/SQL: Statement ignored
create or replace PROCEDURE abc.xyz(year IN number, ver IN number)
IS
cursor my_cur (year IN number, ver IN number) IS
select p1, p2, p3,
p4, p5, p6
from abc.t1
where p2=year
and p3=ver;
my_row my_cur%rowtype;
params varchar2(1000);
BEGIN
for IN my_cur(year, ver) loop
params := '' || my_row.p1 || '' ||','
|| my_row.p2 || ','
|| my_row.p3 || ','
|| my_row.p4 || ','
|| my_row.p5 || ','
|| '' || my_row.p6 || ''
dbms_output.put_line(params);
exec sp2(params);
params := '';
end loop;
END;
答案 0 :(得分:0)
该错误基本上是告诉您该名称没有VALID(已编译)过程,或者您使用不正确的类型/参数数量进行了调用!
您的代码是否已编译?它有2个错误,我在这里发布更正。
CREATE OR REPLACE PROCEDURE abc.xyz (year IN NUMBER, ver IN NUMBER)
IS
CURSOR my_cur (year IN NUMBER, ver IN NUMBER)
IS
SELECT p1,
p2,
p3,
p4,
p5,
p6
FROM abc.t1
WHERE p2 = year AND p3 = ver;
my_row my_cur%ROWTYPE;
params VARCHAR2 (1000);
BEGIN
FOR my_row IN my_cur (year, ver)
LOOP
params :=
''
|| my_row.p1
|| ''
|| ','
|| my_row.p2
|| ','
|| my_row.p3
|| ','
|| my_row.p4
|| ','
|| my_row.p5
|| ','
|| ''
|| my_row.p6
|| '';
DBMS_OUTPUT.put_line (params);
sp2(params);
params := '';
END LOOP;
END;
答案 1 :(得分:0)
这个正在编译
PLSQL块中的exec是无效的语法。 exec是sqlplus begin p的快捷方式;端;
1 create or replace PROCEDURE xyz(year IN number, ver IN number)
2 IS
3 cursor my_cur (year IN number, ver IN number) IS
4 select p1, p2, p3,
5 p4, p5, p6
6 from t1
7 where p2=year
8 and p3=ver;
9 --my_row my_cur%rowtype;
10 params varchar2(1000);
11 BEGIN
12 for my_row IN my_cur(year, ver) loop
13 params := '' || my_row.p1 || '' ||','
14 || my_row.p2 || ','
15 || my_row.p3 || ','
16 || my_row.p4 || ','
17 || my_row.p5 || ','
18 || '' || my_row.p6 || '';
19 dbms_output.put_line(params);
20 sp2(params);
21 params := '';
22 end loop;
23* END;
Procedure created.