Hi All,
After referring to few tutorials, I came to know that the difference between the procedure & function is that procedure may or may not return a value where as function should return a value to the calling program.Given below is my procedure. It would compare the least of two numbers & would return the smallest one
create or replace procedure findmin
(
x in number,
y in number,
z out number
)
is
begin
if(x<y) then
z:=x;
else
z:=y;
end if;
end;
declare
c number;
begin
findmin(23,45,c);
dbms_output.put_line(c);
end;
Here is my function even this does the same thing.
create or replace function findmin_fun
(
x in number,
y in number
)
return number
is
z number;
begin
if(x<y) then
z:=x;
else
z:=y;
end if;
return z;
end;
declare
begin
dbms_output.put_line(findmin_fun(56,28));
end;
I would like to know under what are all the scenarios the procedure & function would be used. And also would like to know could function do the dml operations like insert, update & delete
If so, could you guys explain me with few examples of exhibiting DML opeations in functions