[英]Oracle SP giving PLS-00201 ORA-06550 error
I have created a SP as below: The purpose is the pass 2 params to xyz. 我创建了一个SP,如下所示:目的是将2参数传递给xyz。 The SP xyz will read records from a table t1 and store in a cursor.
SP xyz将从表t1中读取记录并存储在游标中。 xyz in turn will call another SP sp2 in a loop with the records stored in the cursor.
xyz会依次循环使用存储在游标中的记录来调用另一个SP sp2。 When I tried to run this in TOAD, I got the error
当我尝试在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;
The error is basically telling you there is no VALID (compiled) procedure by that name or you called with incorrect type/number of parameters! 该错误基本上是在告诉您没有该名称的VALID(已编译)过程,或者您使用错误的参数类型/数量调用了该过程!
Did your code compile? 您的代码编译了吗? It had 2 errors and i post here with the corrections.
它有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;
This one is compiling 这个正在编译
exec within a PLSQL block is not valid syntax. PLSQL块中的exec无效语法。 exec is a shortcut for sqlplus begin p;
exec是sqlplus begin p的快捷方式; end;
结束;
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.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.