jugluck
asked on
ORA-06553: PLS-306: Error in function
I am working on Oracle 10Gr2 with Windows XP machine.
I have created 2 functions in oracle and I am pasting the code as shown below
i)
create or replace function sp_match_slabs(MU_ID IN VARCHAR2,MU_SET IN INTEGER,CHR_ID IN VARCHAR2,PO_ID IN VARCHAR2,ROUTE_ID VARCHAR2) return number is
chrValue NUMBER;
avLen1 NUMBER := 204;
avLen2 NUMBER := 240;
avLen3 NUMBER := 316;
avLen4 NUMBER := 365;
avLen5 NUMBER := 382;
avLen6 NUMBER := 429;
avLen7 NUMBER := 435;
avLen8 NUMBER := 480;
yield Float:=0;
begin
chrValue := nvl(to_number(sp_get_mu_ch ar(mu_id,m u_set,chr_ id)),-1);
if (
chrValue between avLen1 and avLen2 or
chrValue between avLen3 and avLen4 or
chrValue between avLen5 and avLen6 or
chrValue between avLen7 and avLen8 or
chrValue/2 between avLen1 and avLen2 or
chrValue/2 between avLen3 and avLen4 or
chrValue/2 between avLen5 and avLen6 or
chrValue/2 between avLen7 and avLen8 or
chrValue/3 between avLen1 and avLen2 or
chrValue/3 between avLen3 and avLen4 or
chrValue/3 between avLen5 and avLen6 or
chrValue/3 between avLen7 and avLen8
)
then
yield:= sp_check_yield(po_id,mu_id ,1,ROUTE_I D);
dbms_output.put_line('Yiel d');
dbms_output.put_line(yield );
if (yield<=0.25) Then
return chrValue;
end if;
end if;
return -1;
end sp_match_slabs;
Upon compiling the code I am getting the following error.
ORA-06553: PLS-306: wrong number or types of arguments in call to 'SP_MATCH_SLABS'
What is wrong with the code?
I have created 2 functions in oracle and I am pasting the code as shown below
i)
create or replace function sp_match_slabs(MU_ID IN VARCHAR2,MU_SET IN INTEGER,CHR_ID IN VARCHAR2,PO_ID IN VARCHAR2,ROUTE_ID VARCHAR2) return number is
chrValue NUMBER;
avLen1 NUMBER := 204;
avLen2 NUMBER := 240;
avLen3 NUMBER := 316;
avLen4 NUMBER := 365;
avLen5 NUMBER := 382;
avLen6 NUMBER := 429;
avLen7 NUMBER := 435;
avLen8 NUMBER := 480;
yield Float:=0;
begin
chrValue := nvl(to_number(sp_get_mu_ch
if (
chrValue between avLen1 and avLen2 or
chrValue between avLen3 and avLen4 or
chrValue between avLen5 and avLen6 or
chrValue between avLen7 and avLen8 or
chrValue/2 between avLen1 and avLen2 or
chrValue/2 between avLen3 and avLen4 or
chrValue/2 between avLen5 and avLen6 or
chrValue/2 between avLen7 and avLen8 or
chrValue/3 between avLen1 and avLen2 or
chrValue/3 between avLen3 and avLen4 or
chrValue/3 between avLen5 and avLen6 or
chrValue/3 between avLen7 and avLen8
)
then
yield:= sp_check_yield(po_id,mu_id
dbms_output.put_line('Yiel
dbms_output.put_line(yield
if (yield<=0.25) Then
return chrValue;
end if;
end if;
return -1;
end sp_match_slabs;
Upon compiling the code I am getting the following error.
ORA-06553: PLS-306: wrong number or types of arguments in call to 'SP_MATCH_SLABS'
What is wrong with the code?
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
angellll - I didn't think INTEGER was a key word in Oracle. However, I built a simple table with:
CREATE TABLE test
(
testkey INTEGER,
testname VARCHAR2(40)
);
and it (10g - R2) built the table! I was very surprised. Have you seen INTEGER used before?
Jim
CREATE TABLE test
(
testkey INTEGER,
testname VARCHAR2(40)
);
and it (10g - R2) built the table! I was very surprised. Have you seen INTEGER used before?
Jim
>Have you seen INTEGER used before?
no, but I haven't use ora-10x yet alot ...
so, actually, that would eventually not be the right track, but the calling procedure of this one...
we need more explanations from the author, then
no, but I haven't use ora-10x yet alot ...
so, actually, that would eventually not be the right track, but the calling procedure of this one...
we need more explanations from the author, then
ASKER
Jim:
There was an error in the calling function as you had explained in the first mail.
I have changed the SPs as shown
Main Function:
create or replace function sp_match_slabs(MU_ID IN VARCHAR2,MU_SET IN INTEGER,CHR_ID IN VARCHAR2,routeid IN VARCHAR2) return number is
chrValue NUMBER;
avLen1 NUMBER := 204;
avLen2 NUMBER := 240;
avLen3 NUMBER := 316;
avLen4 NUMBER := 365;
avLen5 NUMBER := 382;
avLen6 NUMBER := 429;
avLen7 NUMBER := 435;
avLen8 NUMBER := 480;
yield Number:=0;
begin
chrValue := nvl(to_number(sp_get_mu_ch ar(mu_id,m u_set,chr_ id)),-1);
if (
chrValue between avLen1 and avLen2 or
chrValue between avLen3 and avLen4 or
chrValue between avLen5 and avLen6 or
chrValue between avLen7 and avLen8 or
chrValue/2 between avLen1 and avLen2 or
chrValue/2 between avLen3 and avLen4 or
chrValue/2 between avLen5 and avLen6 or
chrValue/2 between avLen7 and avLen8 or
chrValue/3 between avLen1 and avLen2 or
chrValue/3 between avLen3 and avLen4 or
chrValue/3 between avLen5 and avLen6 or
chrValue/3 between avLen7 and avLen8
)
then
yield:= sp_check_yield(mu_id,1,rou teid);
dbms_output.put_line('Yiel d');
dbms_output.put_line(yield );
if (yield <= 0.25) Then
return chrValue;
end if;
else
return -1;
end if;
end sp_match_slabs;
This is the callled function
CREATE OR REPLACE FUNCTION Sp_Check_Yield(muId VARCHAR2, muSet NUMBER, routeId VARCHAR2)
RETURN NUMBER IS
projYield NUMBER:= 1.0; -- the projected yield, by default 1
reqWt FLOAT := 0.0;
reqLen FLOAT := 0.0;
reqThck FLOAT := 0.0;
reqWidth FLOAT := 0.0;
avlWt FLOAT := 0.0;
avlLen FLOAT := 0.0;
avlThck FLOAT := 0.0;
avlWidth FLOAT := 0.0;
reducelength Float:=0.0;
reduceweight Float:=0.0;
BEGIN
select muc.CHR_VALUE into avlWidth
from material_unit_characterist ic muc
where muc.mu_id = muId and muc.chr_id = 'av_width';
dbms_output.put_line('avlW idth');
dbms_output.put_line(avlWi dth);
select muc.CHR_VALUE into avlLen
from material_unit_characterist ic muc
where muc.mu_id = muId and muc.chr_id = 'av_length';
dbms_output.put_line('avlL en');
dbms_output.put_line(avlLe n);
select muc.CHR_VALUE into avlThck
from material_unit_characterist ic muc
where muc.mu_id = muId and muc.chr_id = 'thickness';
If(avlThck = 0) then
avlThck := 9.11; -- default thickness
END IF;
dbms_output.put_line('avlT hck');
dbms_output.put_line(avlTh ck);
select muc.CHR_VALUE into avlWt
from material_unit_characterist ic muc
where muc.mu_id = muId and muc.chr_id = 'av_weight';
dbms_output.put_line('avlW t');
dbms_output.put_line(avlWt );
select roc.MAX_VALUE into reqWidth
from route_operation_characteri stic roc
where roc.route_id = routeId and roc.chr_id = 'av_width';
dbms_output.put_line('reqW idth');
dbms_output.put_line(reqWi dth);
select roc.MAX_VALUE into reqLen
from route_operation_characteri stic roc
where roc.route_id = routeId and roc.chr_id = 'tot_length';
dbms_output.put_line('reqL en');
dbms_output.put_line(reqLe n);
reqThck := 9.11; -- default thickness
dbms_output.put_line('reqT hck');
dbms_output.put_line(reqTh ck);
select roc.MAX_VALUE into reqWt
from route_operation_characteri stic roc
where roc.route_id = routeId and roc.chr_id = 'av_weight';
dbms_output.put_line('reqW t');
dbms_output.put_line(reqWt );
If (avlWidth>reqWidth)
Then
if (AvlLen > ReqLen)Then
reducelength:= Avllen-Reqlen;
Else
reducelength:=avlLen;
End if;
reduceweight:= 0.2855*avlwidth*reduceleng th*avlThck ;
projyield:=(0.2855*avlwidt h*reducele ngth*avlTh ck)/avlWt;
dbms_output.put_line('Redu ceLength') ;
dbms_output.put_line(reduc elength);
dbms_output.put_line('proj Yield');
dbms_output.put_line(projY ield);
end if;
RETURN projYield;
END;
And this is how I call the main function
av_length=sp_match_slabs(m u_id,1,'av _length',' routeid')
The problem that I face is that when the 2 stored procedures are tested independently they work fine,but the values are not passed back to the call i.e. av_length doesnt have the value which should be returned to it after invoking this function
Please help
There was an error in the calling function as you had explained in the first mail.
I have changed the SPs as shown
Main Function:
create or replace function sp_match_slabs(MU_ID IN VARCHAR2,MU_SET IN INTEGER,CHR_ID IN VARCHAR2,routeid IN VARCHAR2) return number is
chrValue NUMBER;
avLen1 NUMBER := 204;
avLen2 NUMBER := 240;
avLen3 NUMBER := 316;
avLen4 NUMBER := 365;
avLen5 NUMBER := 382;
avLen6 NUMBER := 429;
avLen7 NUMBER := 435;
avLen8 NUMBER := 480;
yield Number:=0;
begin
chrValue := nvl(to_number(sp_get_mu_ch
if (
chrValue between avLen1 and avLen2 or
chrValue between avLen3 and avLen4 or
chrValue between avLen5 and avLen6 or
chrValue between avLen7 and avLen8 or
chrValue/2 between avLen1 and avLen2 or
chrValue/2 between avLen3 and avLen4 or
chrValue/2 between avLen5 and avLen6 or
chrValue/2 between avLen7 and avLen8 or
chrValue/3 between avLen1 and avLen2 or
chrValue/3 between avLen3 and avLen4 or
chrValue/3 between avLen5 and avLen6 or
chrValue/3 between avLen7 and avLen8
)
then
yield:= sp_check_yield(mu_id,1,rou
dbms_output.put_line('Yiel
dbms_output.put_line(yield
if (yield <= 0.25) Then
return chrValue;
end if;
else
return -1;
end if;
end sp_match_slabs;
This is the callled function
CREATE OR REPLACE FUNCTION Sp_Check_Yield(muId VARCHAR2, muSet NUMBER, routeId VARCHAR2)
RETURN NUMBER IS
projYield NUMBER:= 1.0; -- the projected yield, by default 1
reqWt FLOAT := 0.0;
reqLen FLOAT := 0.0;
reqThck FLOAT := 0.0;
reqWidth FLOAT := 0.0;
avlWt FLOAT := 0.0;
avlLen FLOAT := 0.0;
avlThck FLOAT := 0.0;
avlWidth FLOAT := 0.0;
reducelength Float:=0.0;
reduceweight Float:=0.0;
BEGIN
select muc.CHR_VALUE into avlWidth
from material_unit_characterist
where muc.mu_id = muId and muc.chr_id = 'av_width';
dbms_output.put_line('avlW
dbms_output.put_line(avlWi
select muc.CHR_VALUE into avlLen
from material_unit_characterist
where muc.mu_id = muId and muc.chr_id = 'av_length';
dbms_output.put_line('avlL
dbms_output.put_line(avlLe
select muc.CHR_VALUE into avlThck
from material_unit_characterist
where muc.mu_id = muId and muc.chr_id = 'thickness';
If(avlThck = 0) then
avlThck := 9.11; -- default thickness
END IF;
dbms_output.put_line('avlT
dbms_output.put_line(avlTh
select muc.CHR_VALUE into avlWt
from material_unit_characterist
where muc.mu_id = muId and muc.chr_id = 'av_weight';
dbms_output.put_line('avlW
dbms_output.put_line(avlWt
select roc.MAX_VALUE into reqWidth
from route_operation_characteri
where roc.route_id = routeId and roc.chr_id = 'av_width';
dbms_output.put_line('reqW
dbms_output.put_line(reqWi
select roc.MAX_VALUE into reqLen
from route_operation_characteri
where roc.route_id = routeId and roc.chr_id = 'tot_length';
dbms_output.put_line('reqL
dbms_output.put_line(reqLe
reqThck := 9.11; -- default thickness
dbms_output.put_line('reqT
dbms_output.put_line(reqTh
select roc.MAX_VALUE into reqWt
from route_operation_characteri
where roc.route_id = routeId and roc.chr_id = 'av_weight';
dbms_output.put_line('reqW
dbms_output.put_line(reqWt
If (avlWidth>reqWidth)
Then
if (AvlLen > ReqLen)Then
reducelength:= Avllen-Reqlen;
Else
reducelength:=avlLen;
End if;
reduceweight:= 0.2855*avlwidth*reduceleng
projyield:=(0.2855*avlwidt
dbms_output.put_line('Redu
dbms_output.put_line(reduc
dbms_output.put_line('proj
dbms_output.put_line(projY
end if;
RETURN projYield;
END;
And this is how I call the main function
av_length=sp_match_slabs(m
The problem that I face is that when the 2 stored procedures are tested independently they work fine,but the values are not passed back to the call i.e. av_length doesnt have the value which should be returned to it after invoking this function
Please help
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
angelIIII:
route_id is the actual field from the source table
When i remove the quotes I get the error
ORA-0904: ROUTEID :Invalid identifier
:I feel that the value of the route ID is not being passed correctly thats why I am not getting the result but when I test the function where I manually pass the value of the route Id then I get the expected results
I call it like
av_length:=sp_match_slabs( mu_id,1,'a v_length', 'routeid') ;
Hope this helps
route_id is the actual field from the source table
When i remove the quotes I get the error
ORA-0904: ROUTEID :Invalid identifier
:I feel that the value of the route ID is not being passed correctly thats why I am not getting the result but when I test the function where I manually pass the value of the route Id then I get the expected results
I call it like
av_length:=sp_match_slabs(
Hope this helps
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
@jugluck
>> av_length:=sp_match_slabs( mu_id,1,'a v_length', 'routeid') ;
In the above call, the use of 'av_length' seems fine to me after looking at SELECT ... INTO statements of the Sp_Check_Yield() function. However, i am not convinced about the use of 'routeid'. Is 'routeid' really a value stored in the route_id column of the route_operation_characteri stic table??
>> av_length:=sp_match_slabs(
In the above call, the use of 'av_length' seems fine to me after looking at SELECT ... INTO statements of the Sp_Check_Yield() function. However, i am not convinced about the use of 'routeid'. Is 'routeid' really a value stored in the route_id column of the route_operation_characteri
ASKER
Jinesh:
No 'routeid is not the value of the field route_id.The route operation characteristic table has the field route_id which can take string values like R5000,R5001,R5002 etc.I do suspect that 'routeid' is being passed rather than the actual values of route_id.When I remove the quotes as per angel's response I am getting the error.
ORA00904:Route_ID: Invalid identifier
No 'routeid is not the value of the field route_id.The route operation characteristic table has the field route_id which can take string values like R5000,R5001,R5002 etc.I do suspect that 'routeid' is being passed rather than the actual values of route_id.When I remove the quotes as per angel's response I am getting the error.
ORA00904:Route_ID: Invalid identifier
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Jinesh:
How can I do this?
Thanks
How can I do this?
Thanks
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
It finally worked.
Thanks
Thanks
create or replace function sp_match_slabs(MU_ID IN VARCHAR2,MU_SET IN NUMBER,CHR_ID IN VARCHAR2,PO_ID IN VARCHAR2,ROUTE_ID VARCHAR2) return number is