Thursday, August 23, 2007

Oracle: Function vs Stored Procedure

Difference between procedure and funtion:
  1. Function always have a returns value where as procedure does not have a return value, but you can use OUT parameter for this purpose.
  2. Function can be used in SELECT statement where as procedure can not. eg. SELECT GetName(v_id) FROM DUAL;
  3. You can have DML(Insert, Update, Delete) DDL(TRUNCATE, Drop), TCL(COMMIT, ROLLBACK) in a function but then you can not call that function in any SQL query.

No comments: