Reputation: 13
I have created procedure called NET_SALARY. I'm entering proper arguments Number then also it is gives me error.
Code used to run procedure by me
EXECUTE NET_SALARY(10000,0.15);
I'm getting error as
Error starting at line : 1 in command - BEGIN NET_SALARY(10000,0.5); END; Error report - ORA-06550: line 1, column 7: PLS-00306: wrong number or types of arguments in call to 'NET_SALARY' 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:
create or replace NONEDITIONABLE PROCEDURE NET_SALARY
(
SALARY IN NUMBER ,
C_PCT IN NUMBER ,
TOT_SAL OUT NUMBER
) AS
COMM NUMBER;
GROSS NUMBER;
IT NUMBER;
BEGIN
IF C_PCT IS NULL THEN
GROSS := SALARY;
IT := SALARY*0.1;
ELSE
COMM := SALARY*C_PCT;
GROSS := SALARY+COMM;
IF COMM<500 THEN
IT := GROSS*0.15;
ELSE
IT := GROSS*0.2;
END IF;
TOT_SAL := GROSS - IT;
END IF;
END NET_SALARY;
Upvotes: 1
Views: 648
Reputation: 143083
You're missing the OUT parameter while calling the procedure. Should be e.g.
declare
l_tot_sal number;
begin
net_salary(10000, 0.15, l_tot_sal);
dbms_output.put_line('Total salary is ' || l_tot_sal);
end;
/
From my point of view, as you're calculating something and returning the result, consider using a function instead of a procedure as you can use it in SQL statements, while procedure requires PL/SQL so you can't e.g.
select net_salary(10, 0.1, ???what to put here???) from dual;
If it were a function, you'd
select net_salary(10, 0.1) from dual;
Upvotes: 0