Procedure and function diff

procedure compile once and run at manytime untill it s coding changes
but
function every time will be complied
is it true this statement?????????
any one help me?????????

softsuresh wrote:
is it true this statement?????????
No. It is a smelly statement.
Where did you hear it? Can you share the URL? Perhaps there are more to this.. (would hope so, else it would mean someone has very twisted and warped views of how code compilation works).
There are no differences from a PL/SQL compiler and run-time perspective between a function and a procedure - except when it comes to popping the call stack (as a function will always return a value up the call stack, a procedure not). So procedures and functions are treated the same way by the compiler and the run-time engine. There are no differences between the two so large, that requires the one to be recompiled all the time and the other not.

Similar Messages

  • Diif between Stored procedure and function

    HI
    I want all the differences between Stored procedure and function.
    Even the basic diff is Procedure does not return any value and Function must be...
    Thansk In advance...

    1) Functions are used for computations where as procedures can be used for performing business logic That's an opinion on usage not an actual difference.
    3) You can have DML(insert,update, delete) statements in a function. But, you can not call such a function in a SQL query.Not true. As User defind functons limitations we can use a function that issues DML in a SELECT statement, if it uses the PRAGMA AUTONOMOUS_TRANSACTION.
    4) Function parameters are always IN, no OUT is possibleEasily refutable...
    SQL> CREATE OR REPLACE FUNCTION my_f (p OUT NUMBER) RETURN DATE
      2  AS
      3  BEGIN
      4     p := to_number(to_char(sysdate, 'DD'));
      5     RETURN sysdate;
      6  END;
      7  /
    Function created.
    SQL> var x number
    SQL> var d varchar2(18)
    SQL> exec :d := my_f(:x)
    PL/SQL procedure successfully completed.
    SQL> print d
    D
    18-NOV-05
    SQL> print x
             X
            18
    SQL>
    Stored Procedure :supports deffered name resoultion 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 creationNot sure what this one is about...
    SQL> CREATE PROCEDURE my_p AS
      2      n NUMBER;
      3  BEGIN
      4     SELECT count(*) INTO n
      5     FROM tab1;
      6  END;
      7  /
    Warning: Procedure created with compilation errors.
    SQL> sho err
    Errors for PROCEDURE MY_P:
    LINE/COL ERROR
    4/4      PL/SQL: SQL Statement ignored
    5/9      PL/SQL: ORA-00942: table or view does not exist
    SQL>
    7) A procedure may modifiy an object where a function can only return a value.An ounce of test is worth sixteen tons of assertion...
    SQL> CREATE OR REPLACE FUNCTION my_f2 RETURN VARCHAR2
      2  AS
      3  BEGIN
      4       EXECUTE IMMEDIATE 'CREATE TABLE what_ever (col1 number)';
      5      RETURN 'OK!';
      6  END;
      7  /
    Function created.
    SQL> exec :d :=  my_f2
    PL/SQL procedure successfully completed.
    SQL> desc what_ever
    Name                                      Null?    Type
    COL1                                               NUMBER
    SQL> I think there are only two differences between a procedure and a function.
    (1) A function must return a value
    (2) because of (1) we can use functions in SQL statements.
    There are some minor difference in allowable syntax but they are to do withj RETURN values.
    Cheers, APC

  • How to find out list of procedures and functions inside a package

    How I can find out the list of Procedures and Functions inside a Package.

    Look at ALL_PROCEDURES and ALL_ARGUMENTS.

  • Use of Procedure and Functions in ADF BC

    Hi,
    In ADF 11g
    1. can I use oracle function and procedures ( having in and OUT parameters) to expose as service interface
    2. if yes , How can this be done. and what are the allowed data types as input to procedure/function and can be returned by procedure/function
    3. How the transaction control will be achieved using ADF BC service interface.
    E.g. one ADF BC creates orders in order details and second creates Order lines in Order lines table. Now if order is created successfully but line creation fails then I want order to be rolled back also.
    Thanks.

    google it out.
    How to get two out param which is used in Procedure
    http://sameh-nassar.blogspot.in/2010/01/create-plsql-function-and-call-it-from.html
    http://adf-tools.blogspot.in/2010/09/adf-function-call-from-el-statement-in.html
    http://adf-tools.blogspot.in/2010/03/adf-plsql-procedure-or-function-call.html
    http://adfhowto.blogspot.in/2010/11/call-db-procedure-or-function-from-adf.html
    Re: use of Procedure and Functions in ADF BC

  • Are the Pl/sql procedure and function atomic by themself

    i want to ask a question does oracle pl/sql procedure and function support Atomicity for the database by themself , or they became atomic incase we call them using begin -- end;

    You appear to be discussing transaction scope which is completely independent of PL/SQL blocks like procedures or how you call procedures. It's all in where commits (or rollbacks) are issued.
    If you have a procedure like this
    CREATE PROCEDURE p1
    AS
    BEGIN
      INSERT INTO some_table( key, value ) VALUES( 1, 'Foo' );
      INSERT INTO some_table( key, value ) VALUES( 1, 'Bar' );
    END;where the first statement succeeds and the second statement fails as a result of a duplicate key, there will still be a Foo row in the table but the procedure will have thrown an exception. The caller of the procedure may choose to commit or rollback the change-- that will determine whether the first statement's results are made permanent. If you have a procedure like this,
    CREATE PROCEDURE p1
    AS
    BEGIN
      INSERT INTO some_table( key, value ) VALUES( 1, 'Foo' );
      commit;
      INSERT INTO some_table( key, value ) VALUES( 1, 'Bar' );
    END;the commit will make the first insert permanent regardless of whether the second statement fails no matter what the calling code does (that's one reason that putting commits in stored procedures is generally a bad idea-- the caller is in a much better position to know what other uncommitted work has been done and whether it is safe to commit.
    Justin

  • Procedure and Functions from ADF View Layer

    Hi,
    Before i ask my question ,I would like to mention that I have done lot of googling on this topic before asking this question.
    http://adfhowto.blogspot.in/2010/11/call-db-procedure-or-function-from-adf.html
    http://adf-tools.blogspot.ca/2010/03/adf-plsql-procedure-or-function-call.html
    Lot of threads on otn forum too on this topic.
    I m pretty new to ADf too.
    Now most of our logic is in procedures and functions ,so on various events on form(view layer) I need to call procedure and function and then return values back to value layer too.
    Now the approach mentioned in the link above is good whats best approach to return out parameters to view layer considering i will be using either the DbCall class for all calls to procedures and functions
    I am thinking of this approach to Create a view with static fields,and in Model layer set values for these fields and access them in view layer or binding view controls to these fields.
    From View layer i will call the methods in AppmodImpl which will be calling procedure( methods will be exposed as Client Interface)
    Also in few articles i came across generic CallStoredProcedure and CallStoredFunctions.
    But my main concern is how to share out parameters with view layer....can anyone give link of showing application of it on view layer.
    Regards,

    From your subject. am stating that, dont do all those stuff in backing bean. backing bean is 1:1 mapping with your .jpsx or .jsff .
    best approach would be call those things your Application Module(model layer) exposed it. access the method over your pagedef. well said by ram.

  • How can I use the procedures and functions in my library

    hello, all
    I have a pl/sql library MYLIB.pld, MYLIB.pll and MYLIB.plx.
    How can I invoke procedures and functions there in JDeveloper?
    Thanks.
    Damon

    I am indeed using ADF BC to re-develop the oracle application.
    Here is my situation:
    We have an oracle form application.
    Our objective is to try to re-use the existing sources in the form application as much as possible:
    1. tons of procedures and functions in a pl/sql library(a file with extension name portfolioLib.pll or portfolioLib.plx);
    2. tons of form-level triggers, data-block triggers and item-triggers;
    3. tons of database stored procedures and triggers;
    After doing a research on JDeveloper, we decide to use ADF Swing+ADF BC to re-develop the application.
    My opinion for the above three kinds of sources in our form application is:
    for 1: we try to move most of procedures and functions into database(except Form build-in);
    for 2: we try to wrap those triggers in a SQLJ class;
    for 3: we try to call database procedures and functions with PreparedStatment or CallableStatement;
    I just do a test on a post-query trigger on a data-block:
    I created a sqlj file, named testSQLJ.sqlj in the test.view package;
    I tried to call it in createInstanceFromResultSet of testDeptVOImpl.java which is test.model package,
    I was told that testSQLJ cannot be found there. why?
    How can I call some classes from test.view package in some classes of test.model?
    I read some documents about how to deal with post-query trigger in JDeveloper: create a view with SQL statement, but it seems that it does not support pl/sql statement there.
    Can you give me some opinion about the above stuff?
    I really appreciate your help.
    Damon

  • Differences between procedures and functions.

    a little confusing ..in differences between procedures and functions..
    1. Can a function return only single value?? cant we return multiple values?
    2. Can we use 'out' parameter and 'return' clause at a time in the same function
    thank you

    Hi,
    newbie wrote:
    a little confusing ..in differences between procedures and functions..
    1. Can a function return only single value?? cant we return multiple values?Yes, a function can only return a single value.
    If the return type is some kind of collection or data structure, then that 1 collection or data structure can, of course, actually contain many sep[arate values.
    If you want to return multiple values, use a PROCEDURE with multiple OUT arguments.  (Functions can have OUT arguments, too, but avoid defining functions with OUT arguments.  It can cause a lot of confusion.)
    2. Can we use 'out' parameter and 'return' clause at a time in the same functionSure, but don't take my word for it.  Try it and see.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • What is the difference between procedure and function?

    Hi,
    i want to know the difference between procedure and function.
    Also, i want to know types(if they exists) of procedures and functions .
    Regards

    Also, please try and use the SEARCH functionality offered by the forum, it's always possible someone has asked the question before you.
    Functions vs Stored Procedures
    Is one such instance.

  • Procedure and function

    hi folks,
               procedure and function are doing a same job then why we using function,please give explanation in real time scenario ...

    When talking about PL/SQL only, everything that can be achieved with a function can also be achieved with a procedure using out parameters, thus you don't really need functions.
    However, a function may be used as a "syntactical convenience" in that you can write expressions like this in your PL/SQL code:
    total_salary := get_total_salary(dept_id => my_dept);
    (assuming you have defined the function get_total_salary).
    You may find this more readable than writing
    get_total_salary(result => total_salary, dept_id => my_dept);
    (assuming you have defined the procedure get_total_salary with an out parameter result).
    This is the same as with e.g. the CASE statement. You don't really need it, every CASE statement might be expressed with IF .. THEN statements as well. However using CASE may be more convenient and make your code more readable. Another example are loops, where you have different flavours, while everything might be expressed using one sort of loops (e.g. WHILE).
    In addition, you may use functions in SQL, while this is not possible with procedures, i.e. after defining some function f, you may write SQL like this:
    select * from t where f(id) = 0;

  • How to test procedures and functions of pl/sql

    I am working as a QA basically i got a new assignment of testing functions and procedures, and packeged bodies. Can any one help me in this matter.
    Please help me.
    Hi i am new to oracle I want to test procedures and functions,
    and packaged bodies of pl/sql.

    It depends on what you meant by "testing". I guess you need to check that routines (functions, procedures, packages etc) in valid state and execute without errors. The simpliest way is to get some development tool like TOAD (http://www.quest.com), Oracle Maestro (http://www.sqlmaestro.com) or PL/SQL Developer (http://www.allroundautomations.com). You can connect with them to database and look at the routine state VALID or INVALID. You can recompile them, run and even debug. I guess this should be enough.
    Alternatively you can do same thing from sqlplus. Of course with lesser comfort. You need to write certain SQL statements. For example i want to find invalid procedures:
    SQL> select OBJECT_NAME, OBJECT_TYPE from USER_OBJECTS where STATUS='INVALID';
    To check how procedures work you need to execute anonymous PL/SQL block like this:
    declare
         /* local variables declaration */
         NAME VARCHAR2(4000);
         PRESIDENT_ID NUMBER(38);
         ID NUMBER(38);
    begin
         /* setting up variables */
         NAME:='MICROSOFT';
         PRESIDENT_ID:='BILLY';
         ID:=NULL;
         /* calling routine */
         GEOMETRY.ADD_COMPANY(NAME,PRESIDENT_ID,ID);
    end;

  • Regarding Procedures and functions

    can we pass a cursor,table or ref cursor to a procedure and functions and can a function return cursor,table or ref cursor to a procedure and functions?please if possible give some examples with explanations
    thanks in advance..

    Hi,
    The definition for a Procedure or Function can be edited by selecting Edit from the drop-down menu for the Procedure/Function object in the Browser.
    The definition can then be edited as text, and so Table, REF CURSOR, ... parameters or return types can be added.
    (After completing the edit, select Save from the File menu, or alternatively Close the tab displaying the definition and select Yes to the Save Changes dialog.)
    The Oracle Database PL/SQL Language Reference documentation contains some examples of Procedure and Function definitions.
    David

  • Audit Procedure and Function Execution

    Hello,
    Does anyone know if Data Vault is capable of auditing procedure and function execution?
    Regards,
    Hugo

    Data Vault is a vault ... it does not perform auditing.
    Audit Vault, the title of this forum, is a vault that stores audit trail information ... it is not an auditing creation tool.
    If you want to audit procedure and function execution tell of your version and specifically what metrics you want for your audit trail.
    Also look at the following:
    http://www.morganslibrary.org/library.html
    scroll down to OWA_UTIL
    and look at the WHO_CALLED_ME procedure.

  • Difference  procedure and function

    some tasks solved both procedures and functions.when we go to function and when we
    go to procedure.

    One other difference is "Using the RETURN Statement"
    In procedures, a RETURN statement does not return a value and so cannot contain an expression. The statement returns control to the caller before the end of the procedure.
    In functions, a RETURN statement must contain an expression, which is evaluated
    when the RETURN statement is executed. The resulting value is assigned to the
    function identifier, which acts like a variable of the type specified in the RETURN
    clause.

  • No packages, procedures and functions in Schema Browser

    Hi there,
    SQL Developer 2.1 Early Adopter 2:
    For Databases below 10g in Schema Browser no packages, procedures and functions are visible (no entries under these nodes).
    All other objects are shown correctly.
    Is this a known issue?
    Regards
    Andre

    The thread below seems to have an "official" response to this issue:
    SQL Develpoer EA - 9i Support
    Cheers,
    Chris

Maybe you are looking for