The basic Difference between Functions and procedures is the context in which they should be used.
Functions are used to "Derive" Something based on the inputs , While Procedures are used to "DO" specific tasks.
The videos clarifies all the doubts one may have regarding this topic.
You can watch the random data generation video to populate the sales Table :
Excel Test Data Generation :
• Generate Millions Rows of Data in 2 m...
Oracle Test Data Generation :
• Test Data Generation in SQL with in 1...
Code used in the video :
select * from sales;
CREATE or replace FUNCTION FN_SALES(quantity_in int )
RETURN INT
IS
pragma AUTONOMOUS_TRANSACTION;
BEGIN
UPDATE sales set sales_Quantity=quantity_in * 2;
commit;
return 1;
END;
select FN_SALES(4) from dual;
---Can't have output parameters
create or replace function out_param(outparam out int)
return int is
begin
outparam := 1 ;
return 10;
end;
set serveroutput on ;
declare
return_value int;
output_value int;
begin
return_value:=out_param(output_value);
dbms_output.put_line(return_value);
dbms_output.put_line(output_value);
end;
#TechCoach #OracleInterviewQuestion #PLSQL