Difference between function and procedure

Hi all,
Please send me the difference b/w functions and procedures.
Regards
dskumar

A procedure may(1 or many) or may not return a
value,I have yet to see a procedure returning a value. Whilst it can pass out values using OUT and IN OUT parameters, it doesn't RETURN values.
A function always returns one value.A function may also include OUT and IN OUT parameters to pass back values but it's not recommended.

Similar Messages

  • Exact difference between function and procedure

    exact difference between function and procedure(real time diff.....not like return value, dml....) and function do some work at the same time that work also do procedure..why function

    ranitB wrote:
    1. Function is called Inline a query. A return value is must.
    But, procedure may/may not contain a return value.Not true.
    A function may be called in a query providing it meets certain limitations (no DDL, or transactional statements such as commit/rollback etc.).
    A function does not have to be called from a query, it can be called from other PL/SQL code or from other external applications.
    Regular functions must return a value, though pipelined functions do not...
    SQL> CREATE OR REPLACE TYPE split_tbl IS TABLE OF VARCHAR2(32767);
      2  /
    Type created.
    SQL> CREATE OR REPLACE FUNCTION split (p_list VARCHAR2, p_delim VARCHAR2:=' ') RETURN SPLIT_TBL PIPELINED IS
      2      l_idx    PLS_INTEGER;
      3      l_list   VARCHAR2(32767) := p_list;
      4      l_value  VARCHAR2(32767);
      5    BEGIN
      6      LOOP
      7        l_idx := INSTR(l_list, p_delim);
      8        IF l_idx > 0 THEN
      9          PIPE ROW(SUBSTR(l_list, 1, l_idx-1));
    10          l_list := SUBSTR(l_list, l_idx+LENGTH(p_delim));
    11        ELSE
    12          PIPE ROW(l_list);
    13          EXIT;
    14        END IF;
    15      END LOOP;
    16      RETURN;
    17    END SPLIT;
    18  /
    Function created.
    SQL> SELECT column_value
      2  FROM TABLE(split('FRED,JIM,BOB,TED,MARK',','));
    COLUMN_VALUE
    FRED
    JIM
    BOB
    TED
    MARK... whilst the definition of the function shows a return type, the return statement inside the function simply returns, without a value. That's because the data is passed back through a special "pipeline", and you can write code to show that the data is available to a query as soon as it's piped, and before the function has completed (reached the return statement) if you like.
    A procedure does not return a value (And no an OUT parameter is not a "returned" value, it's a writeable parameter, there's a difference)
    2. There are some limitations in functions which is possbl through procedures.
    Like - Oracle doesn't support DML in functions called in Select queries (using PRAGMA AUTONOMOUS_TRANSACTION will help).Not strictly true. and SQL query is considered to be DML, so a function could perform a query and then be used inside another query...
    SQL> ed
    Wrote file afiedt.buf
      1  create or replace function f_dname(p_deptno in number) return varchar2 is
      2    v_dname varchar2(10);
      3  begin
      4    select dname into v_dname
      5    from   dept
      6    where  deptno = p_deptno;
      7    return v_dname;
      8* end;
    SQL> /
    Function created.
    SQL> ed
    Wrote file afiedt.buf
      1* select empno, ename, f_dname(deptno) as dname from emp
    SQL> /
         EMPNO ENAME      DNAME
          7369 SMITH      RESEARCH
          7499 ALLEN      SALES
          7521 WARD       SALES
          7566 JONES      RESEARCH
          7654 MARTIN     SALES
          7698 BLAKE      SALES
          7782 CLARK      ACCOUNTING
          7788 SCOTT      RESEARCH
          7839 KING       ACCOUNTING
          7844 TURNER     SALES
          7876 ADAMS      RESEARCH
          7900 JAMES      SALES
          7902 FORD       RESEARCH
          7934 MILLER     ACCOUNTING
    14 rows selected.It's been discussed many times on the forum... my favourite here...
    {message:id=1668675}
    Edited by: BluShadow on 17-Sep-2012 09:22

  • Re: Difference between function and procedure

    Hello Oracles Guru’s,
    I am learning Oracle and I am beginner. My question may be simple and not worth to ask but I am sorry
    Why we call Procedures as Stored Procedure but we call functions only functions.
    As per my understanding I think but the objects are stored as objects in the database.
    Please clarify.

    HIJACKED THREAD!
    Please don't hijack another user's thread.
    If you have a question or issue create a new thread and ask it.

  • What is the difference between function and method

    Hey I need help I dont know which is the difference between function and method ?
    Does anybody can ask me this question.
    Thanks

    jverd wrote:
    The first two answers were also correct.Also the blocked message, quoted here for posterity:
    "Tinkerbell" wrote:
    Methods are defined by Java whereas functions are not. ~

  • Difference between Function and Stored Procedure

    Hi guys, i don't understand the exact difference between a function and a stored procedure. I did lot of google but still. Can somebody explain in simple words. Thanks.

    Hi,
    Here's an example of a user-defined function:
    CREATE OR REPLACE FUNCTION     factorial
    (      in_num       IN     PLS_INTEGER
    RETURN     PLS_INTEGER
    DETERMINISTIC
    IS
    BEGIN
         IF  in_num IS NULL
         THEN
              RETURN     NULL;
         ELSIF in_num <= 1
         THEN
              RETURN  1;
         ELSE
              RETURN  in_num * factorial (in_num - 1);
         END IF;
    END     factorial;
    SHOW ERRORSThis function retruns an integer. You can use the function (or, more properly, the integer that it returns) anywhere an integer expression is allowed.
    For example
    SELECT     ROWNUM
    ,     factorial (ROWNUM)     AS f
    ,     loc
    ,     SUBSTR ( loc
                , 1
                , factorial (ROWNUM)
                )          AS s
    FROM     scott.dept;Output:
    `   ROWNUM          F LOC           S
             1          1 NEW YORK      N
             2          2 DALLAS        DA
             3          6 CHICAGO       CHICAG
             4         24 BOSTON        BOSTON

  • Difference between Function and Automated Activity

    Hi All,
    After struggling with a few BPA Suite/JDev compatibility issues over the past few days, we've finally got a basic setup up and running (JDev 11.1.1.1 worked - 11.1.1.2 did not).
    I'm new to BPA and have 2 fairly basic questions - haven't found conclusive answers to these and hence, raising it on this forum...
    1. What is the difference between a "Function" and an "Automated activity" in the BPA Suite? I had expected the latter to translate to a BPEL invoke but what appears to happen is:
    - "Function" tranlsates to a BPEL Scope + Invoke.
    - "Automated activity" translates to a BPEL Scope + Empty Task.
    Based on this, I would not plan to use a "Function" for web service invocations but not sure where I would use the automated activities.
    2. Is there a BPMN construct that would translate to a BPEL "Assign"? I understand that an Assign is fairly low-level and would normally be expected to be filled in by the BPEL developer (and not by the Business Analyst specifying the BPMN model) but it would be quite handy to be able to specify this in BPMN in some cases..
    Thanks..
    TBKol
    Edited by: TBKol on Apr 23, 2010 4:58 AM

    Hi All,
    After struggling with a few BPA Suite/JDev compatibility issues over the past few days, we've finally got a basic setup up and running (JDev 11.1.1.1 worked - 11.1.1.2 did not).
    I'm new to BPA and have 2 fairly basic questions - haven't found conclusive answers to these and hence, raising it on this forum...
    1. What is the difference between a "Function" and an "Automated activity" in the BPA Suite? I had expected the latter to translate to a BPEL invoke but what appears to happen is:
    - "Function" tranlsates to a BPEL Scope + Invoke.
    - "Automated activity" translates to a BPEL Scope + Empty Task.
    Based on this, I would not plan to use a "Function" for web service invocations but not sure where I would use the automated activities.
    2. Is there a BPMN construct that would translate to a BPEL "Assign"? I understand that an Assign is fairly low-level and would normally be expected to be filled in by the BPEL developer (and not by the Business Analyst specifying the BPMN model) but it would be quite handy to be able to specify this in BPMN in some cases..
    Thanks..
    TBKol
    Edited by: TBKol on Apr 23, 2010 4:58 AM

  • Differnce between function and procedure....

    Hi Experts,
    I have query,When will use procedure or function..
    means:
    in what situation we will use fuction,
    and which scenario will use procedure?
    Can you please explain....?
    Thanks in advance....

    992368 wrote:
    Hi Experts,
    I have query,When will use procedure or function..
    means:
    in what situation we will use fuction,
    and which scenario will use procedure?
    Can you please explain....?
    Thanks in advance....Did you try to search this forum. This question has been asked lot of time. The search feature is not very good here may be use GOOGLE with the SITE tag to search. [url http://www.google.com/#safe=strict&output=search&sclient=psy-ab&q=site:forums.oracle.com+function+vs+procedure&oq=site:forums.oracle.com+function+vs+procedure&gs_l=hp.3...6856.24993.0.25236.54.43.6.0.0.0.428.9494.0j10j21j6j1.38.0...0.0...1c.1.15.psy-ab.eIfpP4zL0fM&pbx=1&bav=on.2,or.r_qf.&bvm=bv.47244034,d.cGE&fp=2bbc6037bd7feb17&biw=1024&bih=597]Something like this

  • Use of function and procedures

    when we need to use function rather than procedure or viceversa???

    Welcome to the forum!
    Use a function if you want to use the value it returns as you would use any other expression in a SQL statement:
    SELECT  SYSDATE
    ,       my_function (column1)  AS c1
    ,       UPPER (column2)        AS c2
    FROM    table_x;or in PL/SQL:
    IF  my_function (x) > 0  THEN  ...Use a procedure otherwise; for example, if there is no value to be passed back.
    Functions can have OUT (and IN OUT) arguments, but they can cause confusion. Many people use procedures whenever they need OUT arguemnts, which includes all situations where 2 or more values are passed back.
    Any good book or site on PL/SQL, or any kind of procedural programming, should explain the differences between functions and procedures.
    If you don't have at least that much guidance, it's better not to try using PL/SQL.

  • Doubts in Functions and Procedures

    Hi Everybody,
    Can anybody tell the exact differences between function and the Procedure?
    My doubts are
    1. if procedure can return, and not necessary that it has to return a value,(that means if we want to return and doesnt also we can write procedure) then why do we need function?
    2. I tried to call a function which updates one table in the code,, i got an error saying that the function should not use DML.
    3. I want to know the combination that
    a. can procedure call a function and viceversa?
    b. can function (which uses DML statements)be called from sql statement ?
    and if any other combinations are there let me know with reasons.
    Thanks in advance,
    Vinay

    To elaborate on the already correct answers...
    user12281717 wrote:
    Can anybody tell the exact differences between function and the Procedure?
    My doubts are
    1. if procedure can return, and not necessary that it has to return a value,(that means if we want to return and doesnt also we can write procedure) then why do we need function?Procedures and Functions are self contained blocks of executable code. When that code completes it has to "return" to whatever called it, so both Procedures and Functions do return, however a procedure has an implicit return when it reaches the end of the code (or you can specify the keyword RETURN without any value if you like), whereas a function must contain a RETURN keyword before reaching the END keyword and a value of the correct datatype must be returned by that RETURN keyword.
    Functions must return a value, whereas Procedures do not return any value.
    If values need to be passed back from a procedure then OUT or IN OUT parameters are used, however if values are to be passed back then often it is something that should be considered for being a function rather than a procedure.
    Functions may also contain OUT or IN OUT parameters, but these types of parameters limit the function to use within PL/SQL code only and prevent them from being used in SQL, as the SQL engine will have no variable to pass back the OUT value into. Generally it is considered bad practice to use OUT or IN OUT parameters in functions.
    The underlying internal differences of Functions and Procedures comes down to how values are passed in and returned via the internal stack or via memory references where the parameter is specified as an OUT / IN OUT with NOCOPY. If you're not familiar with writing machine code / assembly language or low level C code, then this concept will probably be alien to you and it will take more than a simple post to explain it.
    2. I tried to call a function which updates one table in the code,, i got an error saying that the function should not use DML.Functions can contain DML, but those functions can only be used from a PL/SQL call to it, not from within a call from an SQL DML itself. i.e. a DML cannot contain further DML.

  • Difference between Macros and subroutine

    Hi all,
    What is the difference between the macros subroutine and function module functinalitywise.;

    Hi,
    Macros can only be used in the program the are defined in and only after the definition.
    Macros can take max 9 parameters.
    Macros are expanded at compilation / generation.
    Subroutines (FORM) can be called from both the program the are defined in and other programs ('perform
    ' of 'perform in program ').
    Subroutines can take any amount of parameters.
    Subroutines are 'expanded' at runtime.
    Functions are just like FORMs, but are intended to be called external.
    Some differences between FUNCTIONs and FORMs:
    The name of a FORM must be unique within the program (two programs can have different FORMs with the same name). A FORM is intended to be called internal (from within the program, however by a 'trick' you can call them external).
    The name of a FUNCTION has to be unique throughout the system. A FUNCTION is intended to be called external (and is thus shared by 'many' programs).
    The latter is more important for programmers and maintenance. Since a FUNCTION is called external, it is important to keep the interface (parameters) the same. The interface of a FORM (which is intended to be called internal) is check when debugging a program (but it is only checked within the program that is debugged). So if the interface of a FORM is changed, but the call to the FORM (perform ) is not, the debugger will notice this and issue an error message.
    In general:
    A MACRO is more or less an abbreviation for some lines of code that are used more than once or twice.
    A FORM is a local subroutine (which can be called external).
    A FUNCTION is (more or less) a subroutine that is called external.
    Since debugging a MACRO is not really possible, prevent the use of them (I've never used them, but seen them in action). If the subroutine is used only local (called internal) use a FORM. If the subroutine is called external (used by more than one program) use a FUNCTION.
    --Excerpt from http://sap.ittoolbox.com/documents/popular-q-and-a/macro-vs-subroutine-1594#
    DATA p_c(10).
    FIELD-SYMBOLS: <fs> TYPE ANY.
    DATA p_old1 TYPE i VALUE 10.
    DATA p_old2 TYPE i VALUE 11.
    DATA p_old3 TYPE i VALUE 12.
    DATA p_old4 TYPE i VALUE 13.
    DATA p_old5 TYPE i VALUE 14.
    DATA p_old6 TYPE i VALUE 15.
    DATA p_old7 TYPE i VALUE 16.
    DATA p_old8 TYPE i VALUE 17.
    DATA p_old9 TYPE i VALUE 18.
    DATA p_old10 TYPE i VALUE 19.
    DATA p_old11 TYPE i VALUE 21.
    DATA p_old12 TYPE i VALUE 22.
    DATA p_old13 TYPE i VALUE 23.
    DATA p_old14 TYPE i VALUE 24.
    DEFINE ADD_MAPPING.
    p_c = &1.
    CONDENSE p_c.
    CONCATENATE 'p_old' p_c INTO p_c.
    ASSIGN (p_c) TO <fs>.
    WRITE <fs>.
    END-OF-DEFINITION.
    DO 14 TIMES.
    ADD_MAPPING sy-index.
    ENDDO.
    http://sap.ittoolbox.com/documents/popular-q-and-a/macro-vs-subroutine-1594
    http://help.sap.com/saphelp_nw2004s/helpdata/en/9f/db972835c111d1829f0000e829fbfe/frameset.htm
    Regards,
    Priyanka.

  • Difference between IS and AS in procedure?

    difference between IS and AS in procedure?

    prakash wrote:
    hi,
    http://www.oracle.com/pls/db111/portal.portal_db?selected=5&frame=#sql_and_pl_sql_languages
    Here you get everything ..
    functionality wise there is no difference between IS , AS of a procedure .
    Thanks,
    P PrakashI think oracle document do not talk about the Difference or No Difference between IS and AS. So i feel this is not a question that need to be pointed to the document.
    To OP
    Basically as others said there is no difference between them. They are just gramatical representation.
    For example when i create a standalone stored procedure i tend to use AS and when i create a procedure inside a package i tend to use IS. Its just the choice you can make.

  • Difference between function module and a method?

    Hi Experts
    Can anybody pls tell me the technical and functional difference between function moduel and a method?
    Thanks
    Sudhansu

    Hi,
    Function modules are procedures that are defined in function groups (special ABAP programs with type F) and can be called from any ABAP program. Function groups act as containers for function modules that logically belong together. You create function groups and function modules in the ABAP Workbench using the Function Builder.
    Function modules allow you to encapsulate and reuse global functions in the R/3 System. They are stored in a central library. The R/3 System contains a wide range of predefined function modules that you can call from any ABAP program. Function modules also play an important role in database updates and in remote communications between R/3 Systems or between an R/3 System and a non-SAP system.
    You can declare methods in the declaration part of a class or in an interface. To declare instance methods, use the following statement:
    METHODS <meth> IMPORTING.. [VALUE(]<ii>[)] TYPE type [OPTIONAL]..
                   EXPORTING.. [VALUE(]<ei>[)] TYPE type [OPTIONAL]..
                   CHANGING.. [VALUE(]<ci>[)] TYPE type [OPTIONAL]..
                   RETURNING VALUE(<r>)
                   EXCEPTIONS.. <ei>..
    When you declare a method, you also define its parameter interface using the additions IMPORTING, EXPORTING, CHANGING, and RETURNING. The additions define the input, output, and input/output parameters, and the return code. They also define the attributes of the interface parameters, namely whether a parameter is to be passed by reference or value (VALUE), its type (TYPE), and whether it is optional (OPTIONAL, DEFAULT).
    Unlike in function modules, the default way of passing a parameter in a method is by reference.
    As in function modules, you can use exception parameters (EXCEPTIONS) to allow the user to react to error situations when the method is executed.
    As in function modules, you can use the RAISE <exception> and MESSAGE RAISING statements to handle error situations.
    Regards,
    Sruthi

  • 1)Now I use Lightrom 5.7 how to upgrade to 6 or CC? 2) What is the difference between 6 and CC vercion? 3) When I used lightromm 3, I could see inEXIF the distance in meters till the object I took, in the later virsions that function disappeared, it is ve

    1)Now I use Lightrom 5.7 how to upgrade to 6 or CC?
    2) What is the difference between 6 and CC version?
    3) When I used lightromm 3, I could see in EXIF the distance in meters till the object I took, in the later virsions that function disappeared, it is very sad  I am stiil waiting and hope that it would be possibble in the new  versions. Or this indication may  possible by setting?

    1)Now I use Lightrom 5.7 how to upgrade to 6 or CC?
    Purchase the standalone upgrade from here: Products
    Download CC version from here: Explore Adobe desktop apps | Adobe Creative Cloud
    2) What is the difference between 6 and CC version?
    See this comparison chart: Compare Lightroom versions | Adobe Photoshop Lightroom CC
    3) When I used lightromm 3, I could see in EXIF the distance in meters till the object I took, in the later virsions that function disappeared, it is very sad  I am stiil waiting and hope that it would be possibble in the new  versions. Or this indication may  possible by setting?
    Rob Cole's ExifMeta plugin displays the Subject Distance field (and much more).  Unfortunately, his Web site appears to be down again.  He used to be very active here, but he hasn't posted in several months.

  • What is the difference between subroutine and function module?

    What is the difference between subroutine and function module?

    Hi,
    they can both return values.
    FMs are mainly used when a routine is to be performed by many programs.
    Subroutines (forms) are generally only executed within one program.
    You can perform routines from other programs, but it's not often done.
    both forms and FMs are reusable modularization units.
    To distinguish we generally say that forms are used for internal modularization and
    FMs are used for external modularization.
    To decide on which to implement, consider whether you need the content to be used just for a limited program
    or wheteher it can be called from many independent programs.
    For the first purpose it is better to implement a form whereas for the second we implement an FM.
    However, ABAP does not isolate the usage context.
    That is; you can call a form from another program within whose code the form is not actually implemented.
    However, this requires attention since the form may utilize global variables.
    The same issue holds for FMs.
    FMs are encapsulated in function groups and function groups may have global variables that can be globally
    used by all FMs inside it.
    Thanks,
    Reward If Helpful.

  • Functional differences between OBISE1 and OBIEE

    Hello,
    beside the licensing restrictions, there are some funtional differences between OBISE1 and OBIEE. I have seen some very neat features in OBIEE which are not implemented in OBISE1, e. g. generating powerpoint or the assistants for bi publisher in word. The actual release of EE is 10.1.3.4.0 and it is 10.1.3.2.1 for SE1. Does anyone know, if SE1 will be upgraded to 10.1.3.4.0? And if yes, will Interactive Dashboards, Answers and BI Publisher in this relaese have the functional range of EE?
    Thanks in advance for your answers.
    Thomas

    Balaa,
    This question has been posted a number of times. Yes, Server, Answers, Dashboards and Publisher are functionally identical in BISE1 and BIEE. You can use BIEE 10.1.3.4.1 to upgrade your BISE1 10.1.3.2.1 (Oracle trust you not to use the stuff you are not licensed to use such as Delivers).
    See my oracle support note document id 743916.1 on metalink3 ...
    Oracle BI SE1: Patch to 10.1.3.4
    Upgrading Oracle Business Intelligence Standard Edition One to higher versions of the underlying components
    "Customers may upgrade to the latest 10.1.3.x versions of the BI components by running the BI Enterprise Edition 10.1.3.x Installer. They will be alerted that there is an installation already present and prompted to preserve the existing configuration. They should choose that option and the installer will leave the existing configuration (to include Repository, Web Catalog, etc) in tact and install the newer versions of the components. Note that when upgrading, all BI components must be upgraded to the same version. Customers may upgrade to the latest versions of Oracle Database 10g or Oracle Warehouse Builder 10g by applying the supported appropriate patches as needed. A note on platform support -- Oracle BI SE One is available for Windows platforms only. Oracle does not support Oracle BI SE One on other platforms. A note on licensing -- By license, customers are restricted to using BI Server, BI Answers, BI Dashboards, BI Publisher, BI Administration Tool, Oracle RDBMS, Oracle Warehouse Builder Core ETL functionality. Note that the BI SE One installation installs all of the BI components -- those listed above as well as Delivers, Office Plug-in, etc. If customers wish to use those additional components they are required to upgrade to a BI Enterprise Edition license."

Maybe you are looking for

  • Problems syncing animated gif files on website

    I am running Photoshop Elements 8 and have createdd a series of 7 animated gif files.  Within each of the 7 files consist of 4 layers(photos) with 5 second intervals in between each layer/photo.  Each of the 7 animated gif files have been uploaded to

  • Error message in FB60

    Hi Gurus, I am posting a vendor invoice using FB60. When I click on Post I get the following error message. Tax code A0 does not appear in any G/L account item. No matter what tax code I use, I get this message. Kindly let me know what can be done re

  • Right Alignment in List Component

    Hi, I want to display the items in javax.microedition.lcdui.List to be right aligned. How can I do that? Thanx in advance

  • How to work around "screen" blending mode in CMYK document?

    The document has been created in CMYK from the start. But I would like to add "glints" over the image and I normally do this by simplyl setting the "glint layer" to "screen" blending mode (when working in RGB color mode). As you all know, this does n

  • Custom Access Level

    Hi All, I am stuck in access control mechanism in BO. Can anyone forward me any documents related or brief on the custom access level & how to apply it in real, because I am failing to apply it accordingly. Thanks.