Results 1 to 9 of 9

Thread: Oracle functions and procedures

  1. #1
    Junior Member
    Join Date
    Sep 2007
    Answers
    1

    Oracle functions and procedures

    what r the differences between function and procedure?


  2. #2
    Junior Member
    Join Date
    Jul 2006
    Answers
    4

    Re: oracle

    Hi,
    The Function should return a value and u can use the function as part of your SQL statement.
    Where as Procedure, we can not use as part of SQL statement. By using the Out Params u can get more than one value.


  3. #3
    Junior Member
    Join Date
    Aug 2007
    Answers
    2

    Thumbs up Re: oracle

    function can be used in the SQL statements anywhere in the WHERE/HAVING/SELECT section where as Stored procedures cannot be.
    functions that return tables can be treated as another rowset. This can be used in JOINs with other tables.
    Of course there will be Syntax differences .




  4. #4
    Junior Member
    Join Date
    Aug 2007
    Answers
    2

    Re: oracle

    1. Procedure takes both input and output parameters but Functions takes only input parameters
    2. Functions cannot return values of type text, ntext, image & timestamps where as procedures can
    3. Functions can be used as user defined datatypes in create table but procedures cannot



  5. #5
    Junior Member
    Join Date
    Sep 2007
    Answers
    1

    Re: oracle

    procedure -->
    it execute as pl/sql stmt
    NO return clause in the header
    Can return none, one or many values,
    Can contain a return stmt

    function -->

    invoke as a part of an expression,
    must contain a return clause in the header
    Must return a single value
    must contain at least one return stmt


  6. #6
    Junior Member
    Join Date
    Jul 2007
    Answers
    7

    Re: Oracle functions and procedures

    A function always returns a value, while a procedure does not. When you call a function you must always assign its value to a variable


  7. #7
    Junior Member
    Join Date
    Jul 2007
    Answers
    7

    Re: Oracle functions and procedures

    Functions are normally used for computations where as procedures
    are normally used for executing business logic.

    Functions MUST return a value, procedures doesn't need to.


    You can have DML (insert,update, delete) statements in a function. But, you cannot call such a function in a SQL query.
    For example, if you have a function that is updating a table, you cannot call that function from a SQL query.
    - select myFunction(field) from sometable; will throw error.


    Function returns 1 value only. Procedure can return multiple values (max 1024).


    Stored Procedure: supports deferred name resolution. Example while writing a stored procedure that uses table named tabl1 and tabl2 etc..but actually not exists in database is allowed only in during creation but runtime throws error Function wont support deferred name resolution. Stored procedure returns always integer value by default zero. where as function return type could be
    scalar or table or table values(SQL Server).
    Stored procedure is precompiled execution plan where as functions are not.


  8. #8
    Junior Member
    Join Date
    Jul 2007
    Answers
    7

    Smile Re: Oracle functions and procedures

    Functions can return value while procedure i mean vb procedures cannot return value


  9. #9
    Moderator
    Join Date
    Jun 2007
    Answers
    2,074

    Re: Oracle functions and procedures

    in oracle function must return a value buit a procedure may or may not returna value or might return more than one value using the out parameter.

    But if you want to return value then,function should be used.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact