Difference

Functions

Procedure

1 A function always returns a value. 1 A procedure may or may not return a value
2. A function can be called using SELECT statement 2. A procedure cannot be called using  SELECT statement
3. Functions are  used for computational logics 3. Procedures are  used for executing business logic.
4. Function returns only one value. 4. Procedure can return multiple values maximum upto 1024
5. A function cannot be called in another function 5. A procedure can be called in another procedure
6. CREATE [OR REPLACE] PROCEDURE <proc_name> [parameters]

IS

Declaration section

BEGIN

Execution section

[EXCEPTION]

[Exception section]

END;

6. CREATE [OR REPLACE] FUNCTION <FUNC_name> [parameters]

Return return_type

IS

Declaration section

BEGIN

Execution section

[EXCEPTION]

[Exception section]

END;

 

7. Create or replace procedure getsal(x in number)

IS

s  employee.salary%type;

begin

select salary into s from employee where empid=x;

dbms_output.put_line(s);

end;

/

 

7. Create or replace function getsal1(x in varchar2) return number

IS

s  employee.salary%type;

begin

select salary into s from employee where empid=x;

return s;

end;

/

8. Calling Procedure:

 

EXEC <proc_name>(actual parameter)

Eg:

Exec getsal(1);

8. Calling Function:

 

Select < func_name >(actual parameter) from dual;

Eg:

Select getsal(1) from dual;

CONTACT US

We're not around right now. But you can send us an email and we'll get back to you, asap.

Sending

©2018 MYBSCIT.com. An initiative by some failures to make student scholars.

or

Log in with your credentials

Forgot your details?