Procedure Vs Function

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • radhikutti
    New Member
    • Sep 2006
    • 5

    Procedure Vs Function

    Hi All,

    Please explain me the Adv and DisAdv between Procedures and functions

    Thanks in Advance
    Radhi
  • richasaraf
    New Member
    • Aug 2005
    • 23

    #2
    Originally posted by radhikutti
    Hi All,

    Please explain me the Adv and DisAdv between Procedures and functions

    Thanks in Advance
    Radhi
    Hi Radhi,
    Function computes a value and returns that value. It should always return one value.
    Procedure excutes certain queries. It does have return but it returns to the program from where it has been called.

    Thanks

    Comment

    • debasisdas
      Recognized Expert Expert
      • Dec 2006
      • 8119

      #3
      In oracle a procedure may or may not return any value or might return more than one value but a function must return only one value.

      Comment

      • Saii
        Recognized Expert New Member
        • Apr 2007
        • 145

        #4
        Function that returns one value can be used in SQL statements just like buit in functions ...

        Comment

        • DEVELOPERatHTS
          New Member
          • Jun 2007
          • 4

          #5
          Procedures VS Functions

          Procedures are traditionally the workhorse of the coding world and functions are traditionally the smaller, more specific pieces of code. In general, if you need to update the chart of accounts, you would write a procedure. If you need to retrieve the organization code for a particular GL account, you would write a function.

          Here are a few more differences between a procedure and a function:

          A function MUST return a value
          A procedure cannot return a value
          Procedures and functions can both return data in OUT and IN OUT parameters
          The return statement in a function returns control to the calling program and returns the results of the function
          The return statement of a procedure returns control to the calling program and cannot return a value
          Functions can be called from SQL, procedure cannot
          Functions are considered expressions, procedure are not
          Last edited by debasisdas; Jun 30 '07, 05:04 AM. Reason: removed link to another forum

          Comment

          • ciciliya
            New Member
            • Feb 2009
            • 1

            #6
            Procedure Versus Function (www.oraclepass port.com)

            Procedure Versus Function

            a. Only function can Return a value (to be precise using the Return keyword)

            b.Procedures can use ‘Return’ keyword but without any value being passed

            c.Functions could be used in select statements, provided they doesn’t do any data manipulation inside and also should not have any OUT, IN OUT parameters.

            For more: pls visit www.oraclepassport.com

            Comment

            • brynbstn7
              New Member
              • Aug 2010
              • 1

              #7
              Out procedure

              After a procedure with an OUT argument completes, how can you access that variable?. Is it correct that you CANNOT set a variable in a calling block to that procedure:

              create procedure outproc(arg1 OUT varchar2)
              etc..

              DECLARE
              v_result varchar2(100)
              v_arg varchar2(1)
              BEGIN
              v_result := outproc(v_arg);

              How do you use an OUT procedure?

              - thanks

              Comment

              Working...