Both stored procedures and functions can return something. Is there any guideline as to when I should use a procedure instead of a function? For example, for returning cursors, what's the advantage of using one over another?
I use functions to return computed values. I can call a function in a SELECT list (for example: SELECT my_function() FROM dual ;) as well as in PL/SQL.
I use procedures to return cursors or to do any type of procedural processing (step by step) where I don't necessarily care about returning a value, only that the steps happen successfully or not.
For More Information
- Dozens more answers to tough Oracle questions from Karen Morton are available.
- The Best Oracle Web Links: tips, tutorials, scripts, and more.
- Have an Oracle or SQL tip to offer your fellow DBAs and developers? The best tips submitted will receive a cool prize. Submit your tip today!
- Ask your technical Oracle and SQL questions -- or help out your peers by answering them -- in our live discussion forums.
- Ask the Experts yourself: Our SQL, database design, Oracle, SQL Server, DB2, metadata, object-oriented and data warehousing gurus are waiting to answer your toughest questions.
Dig Deeper on Oracle stored procedures
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.