Difference between function and procedure

Hi all

My doubt is that the procedure can be used to return multiple values with OUT parameter and function can also be used to do the same if necessary to return multiple values with OUT parameter.

So with this point of view, which is maybe the difference between these types of the two objects. and obviously if necessary to choose one of these two, we'll go to procedure, why not function?

What is perhaps the reason for this?

Thanks in advance.

Kind regards
Vipin Kumar Rai

Nitesh. wrote:
The main difference I between stored procedure and function of stored procedures compiled only once and can be called again and again without be compiled every time, this improves performance and saves time, of other functions to compile every time as is called...

Would you care to show what you mean. To the best of my knowledge this last statement is not correct.

The main difference for procedures and functions it program design.

A procedure should be used for something that is running a process, where nothing is required to be returned.
A function should be used when a value is required to be returned.

Yes, the procedures can have OUT parameters (as can functions) but that is generally considered bad practice. If you have values be returned, you must use a function with an appropriate return type (structured type if necessary) so that all the requirements of data is returned via the return value. IMO the only acceptable practice to use variables is when you use a variable IN OUT for something in a procedure for this element which is manipulated by the procedure, so for example you'd 'ManipulateData (myData); as a procedure rather than "myData: = ManipulateData (myData);" in function, where the latter would be using resources of additional memory (copies of data) in most cases.

Tags: Database

Similar Questions

  • Difference between function and stored procedure

    Hi guys, I don't understand the exact difference between a function and a stored procedure. I have a lot of google but still. Can someone explain in simple terms. Thank you.

    Hello

    Here is 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 ERRORS
    

    This function returns an integer. You can use the function (or, more exactly, the integer returned) everywhere where a whole 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 functionality and corresponding geometric base edge

    Can someone help me with the difference between a function and a corresponding based edge geometric model?

    I understand that:

    o geometric based function corresponding directly uses the intensity of pixels and reason for research and their settings

    o edge based geometric matching first calculates the gradient of the image and then uses this gradient to find features with generalized Hough transformation...

    More information here: documentation OR

    I hope this helps...

  • Differences between process and procedures

    Hi all
    can someone tell me what are the differences between the processes and procedures? Is there a difference between a process with only automatic spots and a procedure?

    If your process dynamically invokes a procedure and your process and procedure called dynamically are in the same project, it will work when it is deployed to the Studio and business.

    However, if your process tries to dynamically call a procedure from another project, you're going to collide in a bug (the null pointer you get). Support may disagree, but on the company dynamically invoke a procedure of a process in a single project via an interface procedure must initiate a procedure in another project successfully if both are deployed on the same engine of the company.

    Suggest that you report it to the Support. If you need a simple project that duplicates the problem, here is a zip file which has two projects. A project is a process that dynamically calls a procedure through an interface. The invoked procedure is in the other project in the zip file.

    http://www.4shared.com/file/182416607/9e9763a4/InvokeProcedureInDifferentProj.html

    This is a project that works and that invokes a procedure successfully when the process and the invoked procedure are both in the same project.

    http://www.4shared.com/file/182420920/5b52f6b4/ProcedureBeingInvokedinSamePro.html

    Dan

  • Doubts in functions and procedures

    Hello world

    Can someone tell the exact differences between function and procedure?

    My doubts are
    1. If the procedure can return and is not necessary it must return a value (in other words, if we want to come back and is not as one can write procedure) then why do we need to function?

    2. I tried to call a function that updates a table in the code, I got an error saying that the function does not use DML.

    3. I want to know the combination that
    procedure a. can call a function and vice versa?
    b. function (which uses DML instructions) can be called from sql statement?
    and if all other combinations are there let me know with reasons.

    Thanks in advance,
    Vinay

    Have you looked at in the [reference Guide and the User Guide for PL/SQL | http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/toc.htm] already?
    http://download.Oracle.com/docs/CD/B19306_01/AppDev.102/b14261/subprograms.htm#i4075
    http://download.Oracle.com/docs/CD/B19306_01/AppDev.102/b14261/subprograms.htm#i4074

    (1) for example: functions can be used in SQL, procedures cannot.
    (2) generally, the methods are used for DML.
    It depends on how you are performing the function:

    hoek&XE> create table t as select 1 col from dual;
    
    Tabel is aangemaakt.
    
    hoek&XE> create or replace function f
      2   return number
      3   as
      4    num number;
      5   begin
      6    update t
      7    set col = 2;
      8    num := sql%rowcount;
      9   return(num);
     10  end;
     11  /
    
    Functie is aangemaakt.
    
    hoek&XE> select f from dual;
    select f from dual
           *
    FOUT in regel 1:
    .ORA-14551: cannot perform a DML operation inside a query
    ORA-06512: at "HOEK.F", line 6
    
    hoek&XE> 
    
    hoek&XE> var num number
    hoek&XE> exec :num := f;
    
    PL/SQL-procedure is geslaagd.
    
    hoek&XE> print :num
    
           NUM
    ----------
             1
    
    hoek&XE> select * from t;
    
           COL
    ----------
             2
    

    Yes 3A)
    No. 3B), see 2.

  • What is the difference between the 2 procedures pls. ?

    What is the difference between the 2 procedures in syntax and bussiness pls.

    CREATE OR REPLACE PROCEDURE Balance_quantity_update
        (V_STORE_ID IN NUMBER,  V_ITEM_SERIAL IN NUMBER) IS
      BEGIN
      UPDATE WH_T_ITEMS A
          SET BALANCE_QTY = ITEM_QTY
          WHERE STORE_ID = V_STORE_ID
          AND ITEM_SERIAL = V_ITEM_SERIAL
          AND ITEM_QTY = (SELECT MAX(ITEM_QTY)
                          FROM WH_T_ITEMS B
                          WHERE A.STORE_ID = B.STORE_ID
                         AND A.ITEM_SERIAL = B.ITEM_SERIAL);
       END;
       /
    CREATE OR REPLACE PROCEDURE Balance_quantity_update
        (V_STORE_ID IN NUMBER,  V_ITEM_SERIAL IN NUMBER) IS
      BEGIN
      UPDATE WH_T_ITEMS A
          SET BALANCE_QTY =MAX(ITEM_QTY)
          WHERE STORE_ID = V_STORE_ID
          AND ITEM_SERIAL = V_ITEM_SERIAL   ;
       END;
       /
    Kind regards

    Abdetu...

    I don't know exactly what you're asking. The query

    UPDATE WH_T_ITEMS A
       SET BALANCE_QTY =MAX(ITEM_QTY)
     WHERE STORE_ID = V_STORE_ID
       AND ITEM_SERIAL = V_ITEM_SERIAL   ;
    

    is not valid SQL from Oracle. As MAX aggregate functions cannot be used in a query like that because Oracle has no idea what you aggregate by. There is nothing preventing Oracle to change the syntax of the SQL language to allow an aggregate be used this way, but there is usually no reason to extend the SQL language like that.

    You can assign the result of a query that included a total of BALANCE_QTY column, i.e.

    UPDATE WH_T_ITEMS A
       SET BALANCE_QTY = (SELECT MAX(ITEM_QTY) FROM <> WHERE <>)
     WHERE STORE_ID = V_STORE_ID
       AND ITEM_SERIAL = V_ITEM_SERIAL   ;
    

    I think I mentioned in some of your previous discussions, a data model where you have a table of ELEMENTS that has an ITEM_QTY and the BALANCE_QTY looks suspicious. You assign the value of the ITEM_QTY column to the BALANCE_QTY on the same line does only increase anxiety.

    Justin

  • difference between GetCtrlBitmap and GetCtrlDisplayBitmap

    What is the difference between functions

    GetCtrlBitmap() and GetCtrlDisplayBitmap()?

    If it's important, this would use CVI 8.5.

    Thank you very much.

    An image control can have an image inside. A digital or graphic control cannot.

    With GetCtrlBitmap, you can retrieve the image that is loaded inside a control image and this alone (without the up-down arrows and other details control framework); with GetCtrlDisplayBitmap you can get a copy of the full control even if the control does not have a bitmap into it (for example a complete digital with the up-down arrows, sign of radix and thus of suite; a graph or stripchart, to which you copy also scale aspect and so on).

  • What is the difference between Fdisk and Chkdsk programs?

    Hello:

    I don't think I have a common question of OS knowledge and I worked a lot with both, however for years so I forgot everything I used to know.  I was talking to someone Executibles MS-DOS command line and this person I know told me in email and I did not at the moment, but he said the following:

    "Fdisk and chkdsk are pretty much the same.

    Being an old Microsoft OS Engineer I knew it was wrong, however I've been retired since almost 20 years and I have not worked with either for a while.  I looked in the KB for articles explaining the difference between fdisk and chkdsk or define at least the two against each other, but there is no specific article I could find.  I remember the days when the scariest user had a problem, but they ran all third party software on their computer and have installed BETA version software etc so I'm sure you know the drill and this type of person.

    The person who said this about fdisk and chkdsk is one of those people.  It is a really nice guy, but a nightmare to Microsoft when you talk to a convenience store to the BONE for assistance.  Is there someone out there who could you, please, help me and summarize an irrefutable definition or description indicating the differences between fdisk and chkdisk?  I don't remember the basic functions both I widely used both, but too many years have passed and I don't want to sound like a fool trying to write about the differences.

    I'd appreciate any help I want to educate my friend and the intention is to not make this person feel like a stupid either.

    Thank you, and I expect your response.

    Eric

    The two are completely different, one is a format utility the other is a utility disk check

    http://support.Microsoft.com/kb/255867/en-us

    Fdisk was used in earlier versions of victory

    http://Windows.Microsoft.com/en-GB/Windows/Fdisk-FAQ#1TC=Windows-7

  • Difference between 'Form' and 'object '.

    I am writing today a guide in my native language and want to understand the difference between 'Object' and 'Form' for Illustrator. We have menu object in the Panel and can find a few options of forms under this menu.

    Also we program this object is:

    In computing, an object can be a variable, a data structure, a function or a methodand as such, is a location in memory value and possibly referenced by an identifier.

    In class-based object-oriented programming paradigm, 'object' refers to an instance of a class where the object can be a combination of data structures, functions, and variables.

    Relational database management, an object can be a table or column or an association between data and entity of database (such as the age of a person concerning a particular person). [1]

    So my question is: If we create a form in artificial intelligence can we call it 'object' and vs. ?

    There is menu item "Create object mosaic" option which works only with raster images. This is why any other object in artificial intelligence is not object?

    Thank you

    "In illustrator is an 'Application based on the objects' any item placed in the drawing area that you can select is called" object "where as".

    a form is an object of two dimension.

    We could say : each form is an object , BUT not every object is a form.

  • JavaScript - the difference between ' window ' and 'document.'?

    Hello

    I'm a Javascript newbie which ended just by the first screen of Captivate (CP9) (HTML5) using Javascript.

    A slide with several text entry areas (TEBs) and a Submit button, which performs a function to validate the TEBs (thank you David for have started me).

    I call the function in the script of the Submit button window and have Javascript code in the Index file.

    In the Javascript code, I used the ' windows ' and 'document '. (don't know if I've used them correctly but the works of Javascript)

    I don't really know the difference between them.

    In Javascript, I know that window is loaded in the browser first, then the document is loaded in the window.

    It's like the window is your browser window and the document is the HTML page inside.

    Also, you can use each of them to access specific properties - and window has a context.

    Some examples of my javascript:

    • window.cpAPIInterface.setVariableValue ("q1_fback", "");         -erase a message of feedback (text of legend with variable) associated with BER
    • document.getElementById("Text_Entry_Box1_inputField").style.border = 'solid red medium. "  -modification of the border of an object invalid BER (red)

    My question is:

    1. What is the difference between ' window ' and "document." in a context of Captivate?

    I will post you more questions to find out how:

    1 use loops to knock down my code

    2 reuse the same function in other slides

    Concerning

    Donal.

    Your assumptions are correct.

    the cpAPIInterface is in the window.

    The Text_Entry_Box1_inputField is in the document, not the window, but you can use:

    window.document.getElementById("Text_Entry_Box1_inputField").style.border = 'solid red medium. "

    Scope of variables depends on how and when they are declared, and it is generally best to limit their scope and not use them globally in the window object. All seem to be available in the cPs variables window.

  • What is the difference between Oracle and MySQL

    Hello

    I would like to know the major difference between Oracle and MySQL. I have a project to generate tables of database XML files, I used the functions XML built oracle XMLELEMENT, XMLAGG XMLATTRIBUTES, XMLFOREST. I really want to know if these functions (or) similar functions are taken into charge/availabe in MySQL.

    I'm having a hard time finding better linux distro to install Oracle11g, so I intend to move to MySQL. Please help, thanks in advance.

    Supported operating system versions are documented - http://docs.oracle.com/cd/E11882_01/install.112/e24321/pre_install.htm#CIHFICFD

    HTH
    Srini

  • What is the difference between LEAD and LAG?

    Hi all
    Please let me know the difference between LEAD and LAG even if both are functions. Analytics, where we can use specific to improve performance.

    Thanks in advance.

    concerning
    PRAMOD

    Pramod salvation,

    pramod62917 wrote:
    Please let me know the difference between LEAD and LAG

    The main difference is in which way is 'research ':
    -Lead will "transfer" in respect of the order by clause
    -Lag goes "back" with regard to the order by clause

    See this example (Basic):

    Scott@my11g SQL>ed
    Wrote file afiedt.buf
    
      1  with t as (
      2  select 'TeamX' team, 1 player_id, 'PlayerA' name from dual
      3  union all select 'TeamX' team, 2 player_id, 'PlayerB' name from dual
      4  union all select 'TeamX' team, 3 player_id, 'PlayerC' name from dual
      5  union all select 'TeamX' team, 4 player_id, 'PlayerD' name from dual
      6  union all select 'TeamZ' team, 1 player_id, 'PlayerJ' name from dual
      7  union all select 'TeamZ' team, 2 player_id, 'PlayerK' name from dual
      8  union all select 'TeamZ' team, 3 player_id, 'PlayerL' name from dual
      9  -- end of sample data --
     10  )
     11  select
     12  team
     13  ,player_id current_play_id
     14  ,name current_name
     15  ,lead(name) over (partition by team order by player_id) next_name
     16  ,lag(name) over (partition by team order by player_id) prev_name
     17* from t
    Scott@my11g SQL>/
    
    TEAM  CURRENT_PLAY_ID CURRENT NEXT_NA PREV_NA
    ----- --------------- ------- ------- -------
    TeamX               1 PlayerA PlayerB
    TeamX               2 PlayerB PlayerC PlayerA
    TeamX               3 PlayerC PlayerD PlayerB
    TeamX               4 PlayerD         PlayerC
    TeamZ               1 PlayerJ PlayerK
    TeamZ               2 PlayerK PlayerL PlayerJ
    TeamZ               3 PlayerL         PlayerK
    
    7 rows selected.
    

    On the first line + (team = TeamX, current_play_id = 1) +, the next_name once PlayerA regarding the order given by +(order by player_id) + team +(partition by team) + playerB. For this line it is not prev_name like no player as an inferior player_id wihtin this team.
    On the 3rd line +(team=TeamX, current_play=3) +, the once next_name PlayerC in regards to the order given by the team PlayerD, the previous is PlayerB.

  • What is the real difference between the following procedures?

    What is the real difference between the following procedures in the DBMS_STATS package:
    GATHER_SYSTEM_STATS
    GATHER_DICTIONARY_STATS

    GATHER_SYSTEM_STATS: System statistics to describe the characteristics of the system hardware, such as i/o and CPU performance and utilization of the query optimizer. When choosing an execution plan, the optimizer evaluates necessary IO and CPU resources for each request. Statistics system helps the query optimizer estimate the costs of IO and CPU, allowing the query optimizer to choose a best execution more accurately plan.
    GATHER_DICTIONARY_STATS: Collect statistics for all items in the dictionary.

  • Difference between DBMS_XMLGEN and DBMS_XMLSQUERY

    Hello

    Can someone let me know the fundamental difference between DBMS_XMLGEN and DBMS_XMLQUERY?



    Thanx

    Published by: Apache on October 13, 2008 23:56

    Directly from the documentation:

    H2. DBMS_XMLGEN 125
    DBMS_XMLGEN package converts the results of a SQL query to the canonical XML format. All takes an arbitrary SQL query as input, converts it to XML format, and returns the result as a CLOB. This package is similar to the DBMS_XMLQUERY package, except that it is written in C and compiled in the kernel. This package can be run only on the database.

    H2. DBMS_XMLQUERY 127
    DBMS_XMLQUERY provides database XMLType functionality. If possible, use DBMS_XMLGEN package integrated into the C instead of DBMS_XMLQUERY.

  • Difference between 'Reload' and "Reload (Override Cache)"?

    Https://support.mozilla.org/en-US/kb/keyboard-shortcuts-perform-firefox-tasks-quickly#w_navigation, what is the difference between 'Reload' and "Reload (Override Cache)"? What makes "ignore cache"?

    Reloading Web pages and cache bypass aims to obtain a new copy of perhaps obsolete or damaged files currently stored in the disk cache.
    You can do it like the first attempt if a normal charging does not seem to provide a version of a Web site or if you are having problems with a Web site otherwise.

    We usually have advice that if you have questions:

    Reload Web pages and ignore the cache to refresh potentially stale or corrupt.

    • Hold down the SHIFT key and click the Reload button
    • Press 'Ctrl + F5' or 'Ctrl + Shift + R' (Windows, Linux)
    • Press 'Command + shift + R' (Mac)

    Clear the cache and delete cookies only from Web sites that cause problems.
    "Clear the Cache":

    • Firefox/tools > Options > advanced > network > content caching Web: 'clear now '.

    'Delete Cookies' sites causing problems:

    • Firefox/tools > Options > privacy > "Use the custom settings for history" > Cookies: "show the Cookies".

    Start Firefox in Safe Mode to check if an extension or theme (Firefox/tools > Modules > Extensions) or if hardware acceleration is the cause of the problems.

Maybe you are looking for