0% found this document useful (0 votes)
23 views4 pages

RDBMS Assignment 2.. Sem-2

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views4 pages

RDBMS Assignment 2.. Sem-2

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Difference between function and stored procedure in RDBMS..

[ASSIGNMENT 2] SEM -2
Difference between function and stored procedure in RDBMS.. [ASSIGNMENT 2] SEM -2

Function Stored Procedure

Always returns a single value; either scalar or a table. Can return zero, single or multiple values.

Functions are compiled and executed at run time. Stored procedures are stored in parsed and compiled state in the
database.

Only Select statements. DML statements like update Can perform any operation on database objects including select and DML
& insert are not allowed. statements.

Allows only input parameters. Does not allow output Allows both input and output parameters
parameters.

Does not allow the use of Try…Catch blocks for Allows use of Try…Catch blocks for exception handling.
exception handling.

Cannot have transactions within a function. Can have transactions within a stored procedure.

Cannot call a stored procedure from a function. Can call a function from a stored procedure.

Temporary tables cannot be used within a function. Both table variables and temporary tables can be used.
Only table variables can be used.

Functions can be called from a Select statement. Stored procedures cannot be called from a Select/Where or Having
statements. Execute statement has to be used to execute a stored
procedure.

Functions can be used in JOIN clauses. Stored procedures cannot be used in JOIN clauses
Difference between function and stored procedure in RDBMS.. [ASSIGNMENT 2] SEM -2

STORE PROCEDURE FUNCTION (USER DEFINED FUNCTION)

Procedure can return 0, single or multiple


values Function can return only single value

Procedure can have input, output parameters Function can have only input parameters

Procedure cannot be called from a function Functions can be called from procedure

Procedure allows select as well as DML


statement in it Function allows only select statement in it

Exception can be handled by try-catch block in a


procedure Try-catch block cannot be used in a function

We can go for transaction management in


procedure We can not go for transaction management in function

Procedure cannot be utilized in a select


statement Function can be embedded in a select statement

Procedure can affect the state of database


means it can perform CRUD operation on Function can not affect the state of database means it can not
database perform CRUD operation on database

Procedure can use temporary tables Function can not use temporary tables

Procedure can alter the server environment


parameters Function can not alter the environment parameters

Procedure can use when we want instead is to Function can use when we want to compute and return a
group a possibly- complex set of SQL
Difference between function and stored procedure in RDBMS.. [ASSIGNMENT 2] SEM -2

STORE PROCEDURE FUNCTION (USER DEFINED FUNCTION)

statements value for use in other SQL statements

You might also like