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
Create or replace PROCEDURE SSp_EmpHoursInfo
(p_EHrsInfo OUT SYS_REFCURSOR)
AS
BEGIN
OPEN p_EHrsInfo FOR
Select
a.personid, a.first_name, a.last_name,c.hoursworked,d.carecentername, c.break
from person a
join employee b on a.personid = b.empersonid
join employee_assigned_care_center c on b.empersonid = c.empersonid
join care_center d on c.empersonid = d.carecenterid
where hoursworked> 10;
END SSp_EmpHoursInfo;
Everytime I am trying to call the store procedure it is giving me this error msg:
Error starting at line : 225 in command -
BEGIN SSp_EmpHoursInfo (hoursworked> 10); END;
Error report -
ORA-06550: line 1, column 3:
PLS-00201: identifier 'HOURSWORKED' must be declared
ORA-06550: line 1, column 52:
PL/SQL: Statement ignored
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:
The problem is very obvious.
BEGIN SSp_EmpHoursInfo (hoursworked> 10); END; is not the proper way of calling it.
The procedure parameter must be the sys_refcursor.
You must use:
DECLARE
OUTPUT_CUR SYS_REFCURSOR;
BEGIN
SSp_EmpHoursInfo (OUTPUT_CUR );
-- USE CURSOR ACCORDINGLY
END;
/
I'm trying to execute a below SP and it throws be the below error:
CREATE OR REPLACE PROCEDURE denodo.CLEAR_INDEX
( INDEX_NAME1 IN VARCHAR2,
INDEX_NAME2 IN VARCHAR2,
IT_WORKED OUT BOOLEAN ) as
BEGIN
IT_WORKED := FALSE;
EXECUTE IMMEDIATE 'drop index ' || INDEX_NAME1;
EXECUTE IMMEDIATE 'drop index ' || INDEX_NAME2;
IT_WORKED := TRUE;
EXCEPTION
WHEN OTHERS THEN
IT_WORKED := FALSE;
END CLEAR_INDEX;
CLEAR_INDEX#0 [JDBC ROUTE] [ERROR] Received exception with message 'ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'CLEAR_INDEX'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
What is going on here? appreciate your help.
This error you generally face when you deal with BOOLEAN datatype as OUT parameter and you try to print it or do any operation with any other inbuilt Oracle packages. You cannot directly use BOOLEAN datatype in dbms_output.put_line or any other DBMS package. For instance,if you want to print the OUT parameter you need to use sys.diutil.bool_to_int.
See below example which demonstrate the error you faced when you try to execute as below:
DECLARE
inx VARCHAR2(100):='ABC';
var BOOLEAN;
BEGIN
CLEAR_INDEX(INDEX_NAME1=>inx ,IT_WORKED =>var);
dbms_output.put_line(var);
END;
You face the issue:
ORA-06550: line 6, column 3:
PLS-00306: wrong number or types of arguments in call to 'PUT_LINE'
ORA-06550: line 6, column 3:
PL/SQL: Statement ignored
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action
To overcome such issue you must execute as below:
DECLARE
inx VARCHAR2(100):='ABC';
var BOOLEAN;
var1 varchar2(10);
BEGIN
CLEAR_INDEX(INDEX_NAME1=>inx ,IT_WORKED =>var);
var1:=CASE WHEN (sys.diutil.bool_to_int(var)) = 1 THEN 'TRUE'
WHEN (sys.diutil.bool_to_int(var)) = 0 THEN 'FALSE'
END;
dbms_output.put_line(var1);
END;
Output:
anonymous block completed
Mine is a similar case, however, a different call to a function, which has return type as Boolean and the input to the function is varchar2.
So, this is what I am doing:
Declare
v_ret1 varchar2(1000);
v_ret BOOLEAN;
Begin
v_ret := CASE WHEN SEI_PROCESS_MF_MNL_INVC_PKG.f_process_mf_mnl_invc(v_ret1) = 1 THEN 'TRUE'
WHEN SEI_PROCESS_MF_MNL_INVC_PKG.f_process_mf_mnl_invc(v_ret1) = 0 THEN 'FALSE'
END;
dbms_output.put_line(v_ret);
end;
I just wanted to see output of v_ret so that I can use that for further decision making. If v_ret is of type Boolean, the output should be either "TRUE" or "FALSE".
logged as the user CC_LOPES I have this procedure:
create or replace PACKAGE BODY "P_MSG_HOTEL" AS
function parse_msg(p_id in number, p_msg in varchar2) return number is
...
end;
That I try to execute from Oracle SQL Developer with
EXECUTE P_MSG_HOTEL.parse_msg(596210657, '#S,358639058787154;E,10;D,05102017145210,05102017145210;G,4046393,51206983,258,8;M,4709;S,0;IO,1,0,0;DI,79DEAD60');
I got this error:
Error que empieza en la línea: 1 del comando :
BEGIN P_MSG_HOTEL.parse_msg(596210657, '#S,358639058787154;E,10;D,05102017145210,05102017145210;G,4046393,51206983,258,8;M,4709;S,0;IO,1,0,0;DI,79DEAD60'); END;
Informe de error -
ORA-06550: línea 1, columna 126:
PLS-00306: wrong number or types of arguments in call to 'PARSE_MSG'
ORA-06550: línea 1, columna 126:
PL/SQL: Statement ignored
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:
Am really excited to know incase you really got the error you mentioned in your question.
Ideally you must had got something like:
*
ERROR at line 1:
ORA-06550: line 1, column 7:
PLS-00221: 'PARSE_MSG' is not a procedure or is undefined
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
But you posted :
Error que empieza en la línea: 1 del comando :
BEGIN P_MSG_HOTEL.parse_msg(596210657, '#S,358639058787154;E,10;D,05102017145210,05102017145210;G,4046393,51206983,258,8;M,4709;S,0;IO,1,0,0;DI,79DEAD60'); END;
Informe de error -
ORA-06550: línea 1, columna 126:
PLS-00306: wrong number or types of arguments in call to 'PARSE_MSG'
ORA-06550: línea 1, columna 126:
PL/SQL: Statement ignored
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:
This looks quiet misleading.
I did the below demo to show what i meant.
CREATE OR REPLACE PACKAGE P_MSG_HOTEL
AS
FUNCTION parse_msg (p_id IN NUMBER, p_msg IN VARCHAR2)
RETURN NUMBER;
END;
/
CREATE OR REPLACE PACKAGE BODY P_MSG_HOTEL
AS
FUNCTION parse_msg (p_id IN NUMBER, p_msg IN VARCHAR2)
RETURN NUMBER
IS
BEGIN
RETURN 1;
END;
END;
On execution the way you showed it gives the error which say :
EXECUTE P_MSG_HOTEL.parse_msg(596210657,
'#S,358639058787154;E,10;D,05102017145210,05102017145210;G,4046393,51206983,258,8;M,4709;S,0;IO,1,0,0;DI,79DEAD60');
Error
*
ERROR at line 1:
ORA-06550: line 1, column 7:
PLS-00221: 'PARSE_MSG' is not a procedure or is undefined
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
This clearly means Oracle is not able to identify your function while execution.
However when i do like:
SQL>
select P_MSG_HOTEL.parse_msg(596210657, '#S,358639058787154;E,10;D,05102017145210,05102017145210;G,4046393,51206983,258,8;M,4709;S,0;IO,1,0,0;DI,79DEAD60') as col
from dualSQL> 2
3 /
COL
----------
1
I get the output.
Or if i use an Anonymous block i get the result.
SQL> DECLARE
x NUMBER;
BEGIN
x :=
P_MSG_HOTEL.parse_msg (
596210657,
'#S,358639058787154;E,10;D,05102017145210,05102017145210;G,4046393,51206983,258,8;M,4709;S,0;IO,1,0,0;DI,79DEAD60');
2 DBMS_OUTPUT.put_line (x);
END;
/
1
PL/SQL procedure successfully completed.
SQL>
So, in short, you cannot use the function the way you are executing.
Don't execute the function directly . either do it inside DBMS_OUTPUT
SET SERVEROUTPUT ON
EXEC DBMS_OUTPUT.PUT_LINE(P_MSG_HOTEL.parse_msg(arg1,arg2));
Or run a query with function in select to get the output.
select P_MSG_HOTEL.parse_msg(arg1,arg2) FROM DUAL;
You cannot use execute command to execute a function, the function return some value that needs to be captured somewhere, Use anonymous block:
declare
f_return number;
begin
f_return := P_MSG_HOTEL.parse_msg(596210657, '#S,358639058787154;E,10;D,05102017145210,05102017145210;G,4046393,51206983,258,8;M,4709;S,0;IO,1,0,0;DI,79DEAD60');
end;
/
I'm currently trying to execute a stored procedure in Oracle PL SQL. I keep running into the same error for the below with execution.
I've tried both execution with the same error
SET SERVEROUTPUT ON;
EXEC get_phone(200.00,500.00);
OR
SET SERVEROUTPUT ON;
DECLARE
c_minprice products.price%type;
c_maxprice products.price%type;
BEGIN
c_minprice := get_phone(200);
c_maxprice := get_phone(500);
END;
ERROR from executing the above:
c_minprice := get_phone(200);
*
ERROR at line 5:
ORA-06550: line 5, column 15:
PLS-00306: wrong number or types of arguments in call to 'GET_PHONE'
ORA-06550: line 5, column 1:
PL/SQL: Statement ignored
ORA-06550: line 6, column 15:
PLS-00306: wrong number or types of arguments in call to 'GET_PHONE'
ORA-06550: line 6, column 1:
PL/SQL: Statement ignored
****Sample Snip-its form my code:
CREATE OR REPLACE PROCEDURE get_phone
(
c_minprice IN products.price%type,
c_maxprice IN products.price%type,
i_result OUT VARCHAR2
) AS
--Checking if starting price range is valid or not
IF c_minprice IS NULL THEN
i_result := 'Starting price range should be valid and cannot be empty';
RAISE V_MINPRICE; -- Raising exception if starting price is null
END IF;
--Checking if end price range is valid or not
IF c_maxprice IS NULL THEN
i_result := 'End price range should be valid and cannot be empty';
RAISE V_MAXPRICE; -- Raising exception if end price is null
END IF;
Your procedure requires three parameters so you have to pass in three parameters
DECLARE
l_result varchar2(100);
BEGIN
get_phone( 200, 500, l_result );
END;
/
should work. Of course, your procedure seems rather pointless. And if the goal is simply to return a result, you really ought to be using a function rather than a procedure with an out parameter.
get_phone expects 3 arguments, c_minprice, c_maxprice and i_result. You are only passing it one number. Pass it the rest of the arguments.