Reputation: 4578
PL/SQL is showing compilation error. Function is working correctly and successfully compiled, but if running pl/sql query then showing compilation.
CREATE OR REPLACE FUNCTION f(
num IN NUMBER,
num2 IN NUMBER,
ans OUT NUMBER
) RETURN number IS
BEGIN
ans := num + num2;
RETURN ans;
END;
CREATE table add1(val1 number(2),val2 number(1),ans number(3));
SET SERVEROUTPUT ON ;
DECLARE
a1 add1.val1%TYPE;
b1 add1.val2%TYPE;
sum add1.ans%TYPE;
BEGIN
WHILE a1!=-99
LOOP
a1 := &a1;
b1 := &b1;
sum := f(a1, b1, sum);
INSERT INTO add1 VALUES(a1, b1, c1);
END LOOP;
END;
Upvotes: 1
Views: 172
Reputation: 1644
You cannot use IN and OUT in functions. Only in procedures. Correct approach is:
create or replace function f(
num number,
num2 number
) return number is
ans number;
begin
ans := num + num2;
return ans;
end;
UPD: Oh, boy! There are too many errors in your code. Maybe you should describe what you are trying to do with all that stuff.
Upvotes: 1