Home » SQL & PL/SQL » SQL & PL/SQL » function vs procedure (toad oracle 10i)
function vs procedure [message #418015] Wed, 12 August 2009 09:07 Go to next message
Messages: 1
Registered: August 2009
Junior Member
I want in oracle. can someone give me small samples?

say i have employee + department tables.i want to write a function in oracle to return all departments with department number less then 50

also whats difference between procedure and function?i need samples.

thank you
Re: function vs procedure [message #418016 is a reply to message #418015] Wed, 12 August 2009 09:17 Go to previous messageGo to next message
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
How would you like these departments returning? As a Ref Cursor, an array, a comma separated list?

The main difference between functions and procedures is that functions have a return value, and can be referenced in SQL statements.
Re: function vs procedure [message #418023 is a reply to message #418015] Wed, 12 August 2009 10:00 Go to previous message
Michel Cadot
Messages: 65088
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
PL/SQL User's Guide and Reference
Application Developer's Guide - Fundamentals

Forgot to mention:

Please read OraFAQ Forum Guide, especially "How to format your post?" section.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code (See SQL Formatter), use code tags and align the columns in result.
Use the "Preview Message" button to verify.
Also always post your Oracle version with 4 decimals.
Post a working Test case: create table and so on along with the result you want with these data.



[Updated on: Wed, 12 August 2009 10:03]

Report message to a moderator

Previous Topic: FOR LOOP statement - Pass parameter from a recordset
Next Topic: search for "returns"
Goto Forum:

Current Time: Wed Jul 26 03:52:13 CDT 2017

Total time taken to generate the page: 0.06225 seconds