Number of args for stored procedure PLS-00306 - oracle

I have problem with calling for my procedure. Oracle scrams
PLS-00306 Error: Wrong number of types of arguments in call to procedure.
With my type declaration procedure has exact the same declaration like in header below. If I run it as separate procedure it works, when i work in ODCI interface for extensible index creation, it throws PLS-00306.
MEMBER PROCEDURE FILL_TREE_LVL
(target_column VARCHAR2, cur_lvl NUMBER, max_lvl NUMBER,
parent_rect NUMBER,start_x NUMBER, start_y NUMBER,
end_x NUMBER, end_y NUMBER)
IS
stmt VARCHAR2(2000);
rect_id NUMBER;
diff_x NUMBER;
diff_y NUMBER;
new_start_x NUMBER;
new_end_x NUMBER;
i NUMBER;
j NUMBER;
BEGIN
{...}
END FILL_TREE_LVL;
STATIC FUNCTION ODCIINDEXCREATE
(ia SYS.ODCIINDEXINFO, parms VARCHAR2, env SYS.ODCIEnv) RETURN NUMBER
IS
stmt VARCHAR2(2000);
stmt2 VARCHAR2(2000);
min_x NUMBER;
max_x NUMBER;
min_y NUMBER;
max_y NUMBER;
lvl NUMBER;
rect_id NUMBER;
pt_tab VARCHAR2(50);
rect_tab VARCHAR2(50);
cnum NUMBER;
TYPE point_rect is RECORD(
point_id NUMBER,
rect_id NUMBER
);
TYPE point_rect_tab IS TABLE OF point_rect;
pr_table point_rect_tab;
BEGIN
{...}
FILL_TREE_LVL('any string', 0, lvl,0, min_x, min_y, max_x, max_y);
{...}
END;

I have no experience in PL/SQL OOP, but I guess the problem occurs because you try to call a member procedure from a static function. A member procedure always needs an object context, which is lacking in the call.

Looks like you're missing a parameter, probably parent_rect I'm guessing:
FILL_TREE_LVL(target_column VARCHAR2,
cur_lvl NUMBER,
max_lvl NUMBER,
parent_rect NUMBER,
start_x NUMBER,
start_y NUMBER,
end_x NUMBER,
end_y NUMBER)
FILL_TREE_LVL('any string', --target_column
0, --cur_lvl
lvl, --max_lvl
min_x, --parent_rect
min_y, --start_x
max_x, --start_y
max_y --end_x
--end_y ???
);

Related

Oracle function returning all columns from tables

I have this function :
CREATE OR REPLACE FUNCTION checkLiveSoccerOdd (p_FIXID VARCHAR2,
p_TYPE VARCHAR2,
p_RES VARCHAR2)
RETURN NUMBER
IS
odd NUMBER;
BEGIN
SELECT O.Odd
INTO odd
FROM LIVE M, ODDS O
WHERE M.FIXID = O.FIXID(+)
AND M.FIXID = p_FIXID
AND O.TYPE = p_TYPE
AND O.RES = p_RES;
RETURN odd;
END;
Now i need to get more columns in query, for example:
Select M.*, O.*
I tried with cursor but I don't get results.
Can anyone help me with this?
Try this:
CREATE OR REPLACE FUNCTION checkLiveSoccerOdd (p_FIXID VARCHAR2,
p_TYPE VARCHAR2,
p_RES VARCHAR2)
RETURN SYS_REFCURSOR
IS
COL SYS_REFCURSOR;
BEGIN
OPEN COL FOR
SELECT M.*,O.*
FROM LIVE M, ODDS O
WHERE M.FIXID = O.FIXID(+)
AND M.FIXID = p_FIXID
AND O.TYPE = p_TYPE
AND O.RES = p_RES;
RETURN COL;
END;

PLSQL variable doesn't get assigned by the given value

I am trying to assign a value from a table type variable to a varchar2 type table
CREATE OR REPLACE PACKAGE BODY TEST_SYS IS
TYPE line_table IS TABLE OF VARCHAR2(32767) INDEX BY BINARY_INTEGER;
PROCEDURE test(
val_ OUT VARCHAR2)
IS
temp_val VARCHAR2(4000);
svalues_ line_Table;
BEGIN
svalues_(1) := '! -$FILE_LINE=EXT01;2017-01;2017-
12;JJ01;;4021;;;;;;;;;;;;USD;;;;;;;;1000;1000;; -';
temp_val := svalues_(1);
val_ := temp_val;
END test;
END TEST_SYS
value assignment seems does not happen in the following statement. Does anybody has a clue on this?
temp_val := svalues_(1);
This example only for problem replicate, It may be not logically enhanced one. only to understand the problem.
Provided you have a package test_sys with code :
CREATE OR REPLACE PACKAGE TEST_SYS IS
PROCEDURE test( val_ OUT VARCHAR2);
END TEST_SYS;
and body of the package :
CREATE OR REPLACE PACKAGE BODY TEST_SYS IS
TYPE line_table IS TABLE OF VARCHAR2(32767) INDEX BY BINARY_INTEGER;
PROCEDURE test( val_ OUT VARCHAR2) IS
temp_val varchar2(4000);
svalues_ line_Table;
BEGIN
svalues_(1) := '! -$FILE_LINE=EXT01;2017-01;2017-12;JJ01;;4021;;;;;;;;;;;;USD;;;;;;;;1000;1000;; -';
temp_val := svalues_(1);
val_ := temp_val;
dbms_output.put_line(val_);
END test;
END TEST_SYS;
and call procedure test, you will be able to get the results as in the following :
SQL> set serveroutput on;
SQL> var str varchar2(4000);
SQL> exec test_sys.test(:str);
PL/SQL procedure successfully completed
str
---------
! -$FILE_LINE=EXT01;2017-01;2017-12;JJ01;;4021;;;;;;;;;;;;USD;;;;;;;;1000;1000;; -

error:PL/SQL: ORA-00904: : invalid identifier

CREATE OR REPLACE PACKAGE pls_check2 AS
PROCEDURE check_proc(p_item_cat NUMBER,
p_sub_cat NUMBER,
p_pack_is NUMBER,
p_pack_name NUMBER,
v1 OUT NUMBER,
v2 OUT NUMBER,
v3 OUT NUMBER,
v4 OUT NUMBER);
PROCEDURE package_info1(param1 NUMBER, param2 NUMBER, param3 NUMBER);
END pls_check2;
CREATE OR REPLACE PACKAGE BODY pls_check2 AS
v1 NUMBER;
v2 NUMBER;
v3 NUMBER;
v4 NUMBER;
PROCEDURE check_proc(p_item_cat NUMBER,
p_sub_cat NUMBER,
p_pack_is NUMBER,
p_pack_name NUMBER,
v1 OUT NUMBER,
v2 OUT NUMBER,
v3 OUT NUMBER,
v4 OUT NUMBER) IS
CURSOR c1 IS
SELECT ic.id
FROM itemcategory ic
WHERE ic.id = p_item_cat;
BEGIN
v1 := p_item_cat;
v2 := p_sub_cat;
v3 := p_pack_is;
v4 := p_pack_name;
FOR c_p IN c1 LOOP
INSERT INTO master_product_table
(SELECT NULL,
NULL,
package_info1(c_p.id, v2, v3)
FROM package);
END LOOP;
DBMS_OUTPUT.put_line('hello');
END;
PROCEDURE package_info1(param1 NUMBER, param2 NUMBER, param3 NUMBER) IS
v_is_incentivized VARCHAR2(20);
BEGIN
SELECT is_incentivized
INTO v_is_incentivized
FROM package pk
WHERE pk.id = 1;
DBMS_OUTPUT.put_line('hi');
END;
END pls_check2;
On compilation following error comes:
Error(18,1): PL/SQL: SQL Statement ignored
Error(33,7): PL/SQL: ORA-00904: : invalid identifier
You're trying to call a PROCEDURE from SQL. That's not allowed (because it doesn't really make sense). Change package_info1 to
function package_info1(param1 NUMBER, param2 NUMBER, param3 NUMBER)
return number;
in the package header and to
function package_info1(param1 NUMBER, param2 NUMBER, param3 NUMBER)
return number IS
v_is_incentivized VARCHAR2(20);
BEGIN
SELECT is_incentivized
INTO v_is_incentivized
FROM package pk
WHERE pk.id = 1;
DBMS_OUTPUT.put_line('hi');
RETURN 1;
END;
in the package body, and it will compile. Nevertheless, I'd really recommend you rename your PACKAGE table - that name is going to cause you pain without end.

Procedure to input number and output varchar2

I need to write a procedure to input let's say a rep_id and then output the rep_name that corresponds to the rep_id.
After that, I need to use another procedure to call the above procedure.
Here is what I have for the first procedure.
create or replace procedure p_inout
(v_rep_id in number)
As
v_first_name varchar2(20);
v_last_name varchar2(20);
begin
select first_name,last_name into v_first_name, v_last_name
from rep
where rep_id = v_rep_id;
dbms_output.put_line(v_first_name||' '||v_last_name);
end p_inout;
/
Execute p_inout(100);
And here is my procedure to call the above procedure
create or replace procedure p_call
is
v_first_name varchar2(20);
v_last_name varchar2(20);
begin
p_inout(100);
dbms_output.put_line(v_first_name||' '||v_last_name);
end p_call;
/
execute p_call
I was able to get the result but one guy told me that my call procedure should be like this
Create or replace procedure p_call
Is
V_name varchar2(20);
Begin
P_inout(100,v_name); --100 is a rep id
Dbms_output.Put_line(v_name);
End;
/
Execute p_call
Doesn't my procedure to call and his call procedure produce the same result?
CREATE TABLE minions (
rep_id DATE CONSTRAINT minions__rep_id__pk PRIMARY KEY,
rep_name NUMBER CONSTRAINT minions__rep_name__nn NOT NULL
CONSTRAINT minions__rep_name__u UNIQUE
)
/
CREATE OR REPLACE PROCEDURE myCatWasSick (
p_rep_id IN minions.rep_id%TYPE,
p_rep_name OUT minions.rep_name%TYPE
)
IS
BEGIN
SELECT rep_name
INTO p_rep_name
FROM minions
WHERE rep_id = p_rep_id;
EXCEPTION
WHEN NO_DATA_FOUND THEN
p_rep_name := NULL;
END myCatWasSick;
/
CREATE OR REPLACE PROCEDURE releaseTheBadgers
IS
the_badger NUMBER(10);
BEGIN
myCatWasSick( SYSDATE + 1, the_badger );
// Do something with the_badger.
END releaseTheBadgers;
/

How can I call a function inside a procedure in plsql

I want to call a function inside a procedure and get it's value so I can use within the procedure but I have no idea how to do that ??
Any ideas ??
My function is the following one , this function returns a collection of employees' ids whose salary out of the max or min salary , I want to use this value in a procedure to update the salaries of those employees to the minimum salary ??
create or replace procedure P
a_variable_name number;
begin
a_variable := a_function('a parameter');
end;
/
Here is the sample code that will help you calling a function from a procedure.
create or replace FUNCTION ADD_TEN(P_IN VARCHAR2) RETURN VARCHAR2
AS
L_RESULT VARCHAR2(4000);
BEGIN
L_RESULT:=P_IN+10;
RETURN L_RESULT;
END;
create or replace PROCEDURE CALL_FUNCTON(P_IN VARCHAR2)
AS
L_FINAL_RESULT VARCHAR2(4000);
BEGIN
L_FINAL_RESULT:=ADD_TEN(P_IN);
DBMS_OUTPUT.PUT_LINE(L_FINAL_RESULT);
-- USE L_FINAL_RESULT IN YOUR BUSINESS LOGIC
END;
EXECUTE CALL_FUNCTON(5);
declare
procedure my_proc;
function my_func return number is
begin
my_proc;
return 3;
end my_func;
procedure my_proc is
begin
dbms_output.put_line('22');
end my_proc;
begin
dbms_output.put_line(my_func);
end;

Resources