Thursday, 31 January 2013

Differentiate between pl/sql functions and procedures

The following are the major differences between PL/SQL procedure and function:

1. Procedure can performs one or more tasks where as function performs a specific task.
2. Procedure may or may not return value where as function should return one value.
3. we can call functions in select statement where as procedure we cant.
4. We can call Stored Procedure within function but we can not call function within stored procedure.
5.A FUNCTION must be part of an executable statement, as it cannot be executed independently where as procedure represents an independent executable statement.
6. Function can be called form SQL statement where as procedure can not be called from the SQL statement.
7. Function are normally used for computation where as procedure are normally used for executing business logic.
8. Stored procedure supports deferred name resolution where as function wont support.
9. Stored procedure returns always integer value by default zero. whrer as function returns type could be scalar or table or table value.
10.Stored procedure is precompiled execution plan where as function are not.

3 comments:

  1. brillant piece of information, I had come to know about your web-page from my friend hardkik, chennai,i have read atleast 9 posts of yours by now, and let me tell you, your webpage gives the best and the most interesting information. This is just the kind of information that i had been looking for, i'm already your rss reader now and i would regularly watch out for the new posts, once again hats off to you! Thanx a million once again, Regards, sql and plsql difference

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete