Using Oracle SQL Developer I created a simple procedure. The procedure compiles successfully, but when I type the command:
execute CMPPROJECTPROCSELECT();
BEGIN CMPPROJECTPROCSELECT(); END;
I get the following errors:
Error starting at line : 1 in command -
execute CMPPROJECTPROCSELECT()
Error report -
ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'CMPPROJECTPROCSELECT'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:
Error starting at line : 2 in command -
BEGIN CMPPROJECTPROCSELECT(); END;
Error report -
ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'CMPPROJECTPROCSELECT'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:
Please help me to solve this. I know it's a small error. Also I have specified the data types, declarations of names correctly.
My procedure code is
CREATE OR REPLACE PROCEDURE CMPPROJECTPROCSELECT(
p_projectname IN VARCHAR2,
p_description OUT VARCHAR2)
IS
BEGIN
SELECT DESCRIPTION
INTO p_description
FROM CMPPROJECT
WHERE PROJECTNAME = p_projectname;
EXCEPTION
WHEN NO_DATA_FOUND THEN
p_description:= NULL;
COMMIT;
END CMPPROJECTPROCSELECT;
execute CMPPROJECTPROCSELECT();
BEGIN CMPPROJECTPROCSELECT();
END;
EXECUTE is SQL*Plus command.
You are not passing the required parameters to the procedure. You have declared two parameters for your procedure:
p_projectname IN VARCHAR2,
p_description OUT VARCHAR2
So, you need to declare the required parameters and then pass it to the procedure:
DECLARE
proj_desc VARCHAR2(2000);
BEGIN
CMPPROJECTPROCSELECT('project_name', proj_desc);
-- use the OUT value of proj_desc later
END;
/
On a side note, you do not need COMMIT at all. It is required to permanently commit a DML and has nothing to do with a SELECT ..INTO clause.
SELECT DESCRIPTION INTO p_description FROM CMPPROJECT WHERE PROJECTNAME = p_projectname;
EXCEPTION
WHEN NO_DATA_FOUND THEN
p_description:= NULL;
COMMIT; -- You don't need COMMIT at all
UPDATE A working demonstration:
In PL/SQL:
SQL> CREATE OR REPLACE PROCEDURE get_emp(
2 p_ename IN VARCHAR2,
3 p_job OUT VARCHAR2)
4 IS
5 BEGIN
6 SELECT job INTO p_job FROM emp WHERE ename = p_ename;
7 END;
8 /
Procedure created.
SQL> sho err
No errors.
SQL> set serveroutput on
SQL> DECLARE
2 job VARCHAR2(20);
3 BEGIN
4 get_emp('SCOTT',JOB);
5 DBMS_OUTPUT.PUT_LINE('The output is '||job);
6 END;
7 /
The output is ANALYST
PL/SQL procedure successfully completed.
In SQL*Plus:
SQL> VARIABLE JOB VARCHAR2(20);
SQL> EXECUTE get_emp('SCOTT', :JOB);
PL/SQL procedure successfully completed.
SQL> PRINT JOB;
JOB
--------------------------------
ANALYST
Related
1.I have been trying to fetch 1 column from a table using reference cursor in plsql, table only has 11 column lang_cur is the declared cursor.
create or replace PACKAGE MOVIE_PKG
AS
PROCEDURE lang_display(lang_cur out SYS_REFCURSOR);
END MOVIE_PKG;
create or replace PACKAGE BODY MOVIE_PKG
AS
PROCEDURE lang_display(lang_cur out SYS_REFCURSOR)
as
begin
OPEN lang_cur FOR select lang_name from LANGUAGE_SELECT;
end lang_display;
END MOVIE_PKG;
declare
lang_cur SYS_REFCURSOR;
begin
movie_pkg.lang_display(lang_cur);
for data in lang_cur
loop
dbms_output.put_line('langauge:'||data.lang_name);
end loop;
end;
GETTING THIS ERROR
ORA-06550: line 5, column 13:
PLS-00221: 'LANG_CUR' is not a procedure or is undefined
ORA-06550: line 5, column 1:
PL/SQL: Statement ignored
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:)```
You can use FETCH:
declare
lang_cur SYS_REFCURSOR;
lang_name LANGUAGE_SELECT.LANG_NAME%TYPE;
begin
movie_pkg.lang_display(lang_cur);
LOOP
FETCH lang_cur INTO lang_name;
EXIT WHEN lang_cur%NOTFOUND;
dbms_output.put_line('langauge:'||lang_name);
END LOOP;
CLOSE lang_cur;
END;
/
db<>fiddle here
I try to write select procedure in oracle.but it compile success, when I try to execute it given error.
set serveroutput on;
CREATE OR REPLACE PROCEDURE retrieve_decrypt(
custid in NUMBER,
column_name in VARCHAR2,
test_value OUT VARCHAR2
)
AS
BEGIN
-- enc_dec.decrypt(column_name,password) into test_value from employees where custid=5;
COMMIT;
END;
/
set serveroutput on;
EXEC retrieve_decrypt(5,'creditcardno');
the error says ,
This is your procedure:
SQL> create or replace procedure retrieve_decrypt
2 (custid in number,
3 column_name in varchar2,
4 test_value out varchar2
5 )
6 as
7 begin
8 -- your code goes here
9 null;
10 end;
11 /
Procedure created.
SQL>
This is how you call it (and get the error):
SQL> exec retrieve_decrypt(5, 'creditcardno');
BEGIN retrieve_decrypt(5, 'creditcardno'); END;
*
ERROR at line 1:
ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'RETRIEVE_DECRYPT'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
SQL>
The cause of the error is:
the procedure contains 3 parameters:
2 of them are IN - you provided their values
1 of them is OUT - you didn't provide it and got the error
Here's what you should have done: as the 3rd parameter is OUT, you'll have to DECLARE it:
SQL> declare
2 l_out varchar2(20);
3 begin
4 retrieve_decrypt(5, 'creditcardno', l_out);
5 end;
6 /
PL/SQL procedure successfully completed.
SQL>
EXEC you used is a SQL*Plus command so it might not work everywhere; DECLARE-BEGIN-END block will so I'd suggest you use it.
Alternatively, in SQL*Plus, it could be rewritten as
SQL> var l_out varchar2
SQL>
SQL> exec retrieve_decrypt(5, 'creditcardno', :l_out);
PL/SQL procedure successfully completed.
SQL>
but - once again - you'd better use DECLARE-BEGIN-END PL/SQL block.
The initial error is:
wrong number or types of arguments in call to 'RETRIEVE_DECRYPT'
The procedure requires 3 parameters. You are only passing 2 (or apparently only 1, in the attempt that generated the error message shown).
Why do you also see the message "Usually a PL/SQL compilation error"? The EXEC command in SQLPlus creates a PL/SQL block containing the text you provide, and sends that to Oracle for execution. Oracle attempts to compile that PL/SQL block (just like it compiles the procedure when you create it). In this case, the compilation fails because of the mismatch in the number of arguments.
This question already has answers here:
How to test an Oracle Stored Procedure with RefCursor return type?
(6 answers)
Closed 5 years ago.
I create the procedure to output multi rows and columns.
create or replace PROCEDURE MYPROC(
C1 OUT SYS_REFCURSOR )
AS
BEGIN
OPEN C1 FOR SELECT * FROM A_TABLE;
END MYPROC;
There is no error when I compiled it.
But I Can't call my procedure as normal like
Exec MYPROC;
I've got this error.
Error report -
ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'MYPROC'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:
But when I run without script, it displayed my expected result.
So please help me how can I execute this procedure?
Thank You.
Error is because you are not passing any parameter to the procedure when it expects 1.
You need define a refcursor variable and then pass the variable into the procedure and finally read it.
var cur refcursor;
exec MYPROC(c1 => :cur);
print cur;
or
var cur refcursor;
begin
MYPROC(c1 => :cur);
end;
/
print cur;
I have the following simple script.
declare
begin
null;
end;
create table &&DB_SCHEMA..test_table (
test_column varchar(20)
);
Executing it ends with the following error
ORA-06550: line 6, column 1:
PLS-00103: Encountered the symbol "CREATE"
00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:
Can't I use the DDL directly after an anonymous block? Am I forced to do it with EXECUTE IMMEDIATE inside the anonymous block?
You are simply missing a '/':
SQL> declare
2 begin
3 null;
4 end;
5 /
PL/SQL procedure successfully completed.
SQL> create table create_test_table (
2 test_column varchar(20)
3 );
Table created.
Here you find something more.
I'm trying to run a concurrent request in APPS but i keep getting this error
(Cause: FDPSTP failed due to ORA-06550: line 1, column 7:
PLS-00221: 'XXINV_ITEM_ORACLE_E5B0' is not a procedure or is undefined
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored)
and heres my package body its just a simple insert.
CREATE OR REPLACE PACKAGE BODY APPS.XXINV_ITEM_ORACLE_E5B0 IS
PROCEDURE inv_com_proc (
o_chr_errbuf OUT VARCHAR2,
o_num_retcode OUT NUMBER
)
AS
begin
EXECUTE IMMEDIATE 'TRUNCATE TABLE XXINV.XXINV_ITEM_ORACLE_E5B0';
Insert into XXINV.XXINV_ITEM_ORACLE_E5B0(ORGANIZATION_CODE ,
ITEM_NUM,
ON_HAND_QUANTITY ,
ITEM_TYPE ,
STATUS ,
MATERIAL_COST ,
MATERIAL_OVERHEAD_COST,
RESOURCE_COST,
OVERHEAD_COST,
OUTSIDE_PROCESSING_COST,
SUBINVENTORY_CODE ,
LOCATORS )
select OWNING_ORG_CODE, ITEM_NUMBER, ON_HAND_QUANTITY, ITEM_TYPE, STATUS, MATERIAL_COST ,
MATERIAL_OVERHEAD_COST,
RESOURCE_COST,
OVERHEAD_COST,
OUTSIDE_PROCESSING_COST,
SUBINVENTORY_CODE ,
LOCATOR
from apps.XXRPT_INV_VALUATION_D535_V
where apps.XXRPT_INV_VALUATION_D535_V.SUBINVENTORY_CODE = 'FG' AND apps.XXRPT_INV_VALUATION_D535_V.STATUS = 'ONHAND';
COMMIT;
END;
end XXINV_ITEM_ORACLE_E5B0;
When you define the Concurrent Program Executable in System Administration, make sure you the Execution File Name includes the schema.package.procedure, as in APPS.XXINV_ITEM_ORACLE_E5B0.inv_com_proc (no parenthesis).
It seems you're trying to execute the package itself - that won't work. You must execute a procedure/function within the package:
DECLARE
o_chr_errbuf VARCHAR2(256);
o_num_retcode NUMBER;
BEGIN
APPS.XXINV_ITEM_ORACLE_E5B0.inv_com_proc ( o_chr_errbuf, o_num_retcode);
END;
/
A simple test:
DECLARE
err VARCHAR2(256);
CODE NUMBER;
BEGIN xx(err, CODE); END;
ORA-06550: line 5, column 7:
PLS-00221: 'XX' is not a procedure or is undefined
ORA-06550: line 5, column 7:
PL/SQL: Statement ignored
SQL> SELECT * FROM a;
ID
---------------------------------------
SQL> DECLARE
2 err VARCHAR2(256);
3 CODE NUMBER;
4 BEGIN
5 xx.tst(err, CODE);
6 END;
7 /
PL/SQL procedure successfully completed
SQL> SELECT * FROM a;
ID
---------------------------------------
1