function or procedure?

I'm confused whether to use the procedure or function below 2 special issue - procedure, but sure that no return value of procedure doesnot but 2F of the task, we check out the 2nd group iam. This disturbs me is all the same to write 2nd task as procedure and perform the following steps or should I use function for 2nd task.

Cumulative 2nd task spends point procedure
You create a stored procedure called spRollupExpenseItem. This procedure updates
the corresponding line in the BudgetItem table given a report of expenses and the expense category number
number. The procedure contains three input parameters, the value of ERNo, the value of ECNO.
and the amount of cumulative, as well as a single parameter of Boolean result.
This is the logic of the procedure.
· If the corresponding ExpenseReport line (ERStatus) status is DENIED or
MEANWHILE, an application error is triggered. The output parameter is set to False.
· Otherwise, the corresponding BudgetItem line is updated. The actual amount (BIActual) in the
line corresponding BudgetItem are incremented by the input of the cumulative amount parameter.
o the output parameter is set to True after running the update
operation.


2f task create Rollup fees trigger
You create a trigger called TR_RollupExpAmt. This trigger fires after the power to the
approved expenses amount (ExpApprAmt) or the deletion of a row in the table ExpenseItem. The
following points explain the logic of this trigger:
· If updating the ExpApprAmt column, the cumulative amount should be the difference
of the New.ExpApprAmt under the Old.ExpApprAmt.
· If the deletion of a row of the table of ExpenseItem, the cumulative amount should be the
the Old.ExpApprAmt negative.
· To run the update rollup, you must call the spRollupExpenseItem procedure
described in the 2nd special.
· If the output of the spRollupExpenseItem procedure parameter is true, insert a line
in the table (Log_Table) exception log.
o the ExcText (message explaining the error) value should indicate the
operation (update or delete) and the cumulative amount.
o If the output of the spRollupExpenseItem procedure parameter is false,
do nothing.

Hello

What you describe for 2nd task is a process with different business logic. I think that the most important aspect of the 2nd task is the fact that you have an exception defined by the user when a line is REFUSED or pending.
I would like to do a procedure as a function means a very narrow specific result while your task is multi - fold.

Aternatively create a package and task2e is divided into a function and procedure - something like that.
-create a function that takes a varchar2 as a parameters and returns true or false depending on whether the line is DENIED / pending
-Create a procedure calls above function and performs the necessary exception handling
continue in the same procedure
do update

P;

Tags: Database

Similar Questions

  • ORA-00904 during execution of the functions and procedures (IDE version 4.1.0.19)

    Recently, I updated my Oracle SQL Developer to the latest version (see below) and now when I try to run the function or procedure of the IDE, I had an alert with the error: "ORA-00904:"OBJECT_ID": invalid identifier." Code provider 904 ". Previous version of IDE works pretty well. What is the problem?

    Oracle SQL Developer 4.1.0.19

    Version 4.1.0.19

    Build a HAND - 19.07

    It seems that OBJECT_ID added to ALL_PROCEDURES for the 10g DB version, but after the version you have (10.2.0.1.0).  I don't have a link to the documentation specific to hand Oracle, but see the last comment by Steven Feuerstein in the next blog...

    PL/SQL challenge: ALL_PROCEDURES changes over version (5980)

    Typically when generation SQL for a particular version of the DB with SQL Developer, only major (10) and (more rarely) secondary numbers (2) gets checked, if your problem is one of those borderline cases that are easy to miss and less likely to get fixed. Whenever a customer has a specific need to use an older version, Oracle expects usually only the last set of patch (for example, 10.2.0.5) would be used.

  • How to move the functions and procedures of packages in a schema?

    Hello

    I have less than the needs for a work at home and my question is if anyone can point me in the right direction to find documentation that can help me solve below. Any information will be appreciated. Thank you.

    Write procedures and functions (included or not in packets) as .txt or .sql scripts. Once they have been launched in Developer SQL they should, in addition, the functions and procedures of packages in the current schema. If the current schema contains only 2 packages, pac1 (p11, p12 procedures and functions f11, f12, f13) and pac2 (contains the p21 following procedures, p22, p23 and f21 and functions f21 (case of overload), running the scripts produce the following effects:)

    • Procedures p11, p12, p21, p22, p23, and f11, f12 and f13 functions will be created in the current schema.
    • PAC2 will contain 2 instances of the function of overload-f21; they will be kept in the package, without be created in the current schema. If all overloaded procedures/functions will be kept in their original packaging
    • If pac1 contains variables, cursors, and public types, keep us only the details of the package (and remove the body); usually if the packages contain no overloaded functions or procedures the body will be removed and if no variable, cursors, types of public then we will remove the header.
    • If in the triggers, procedures and functions we will call procedures/functions packages (procedures and functions moved into the current schema) they reference will need to be updated (via editing the body or recompilation) for example if pa1.p12 will be replaced with p12.
    • Scripts must have numbers in the next series (01... n) and the characters that explain the content.

    My only advice would be to remember that these are public forums and if YOU can find them, therefore cannot your instructors.

    In addition, those are horrible procedure names and function

    This mission seems to be around to overload the pl/sql objects and... prioritize a research on Oracle documentation around overhead and legacy
    http://docs.Oracle.com/CD/B28359_01/AppDev.111/b28371/adobjplsql.htm#i21148

  • Using the values of default setting with the functions or procedures?

    If you have a procedure or a function that has DEFAULT values reported for some parameters How do you call this function or procedure when you want to use some of the default values? I tried...

    myProcedure(202,,);
    myProcedure (202, ",");
    myProcedure(202,null,null);
    myProcedure (job_id = 202);
    myProcedure (job_id = > 202);

    None of the above worked.

    PROCEDURE add_job (job_id IN jobs.job_id%TYPE
    job_loc IN jobs.job_location%TYPE DEFAULT 145
    mgr_id IN DEFAULT jobs.mgr_id%TYPE 30
    );

    Thank you.

    EDIT: I will say that it is a simplified example. Imagine you please a parameter list much more great and perhaps half having DEFAULT values. Thank you.

    PROCEDURE myProcedure (job_id IN jobs.job_id%TYPE
    job_loc IN jobs.job_location%TYPE DEFAULT 145
    mgr_id IN DEFAULT jobs.mgr_id%TYPE 30
    init_id IN jobs.init_id%TYPE
    sal_id IN jobs.sal_id%TYPE 100 by DEFAULT
    , clock_id IN DEFAULT jobs.clock_id%TYPE "A".
    shift_id IN jobs.shift_id%TYPE
    , lot_id IN DEFAULT jobs.lot_id%TYPE «BACK»
    );

    Published by: davejjj on March 20, 2013 16:47

    Hi davejjj,

    Here is an example of calling your myprocedure. This example uses default values for sal_id, clock_id, lot_id

    declare
      procedure myprocedure (
        job_id     in jobs.job_id%type,
        job_loc    in jobs.job_location%type default 145,
        mgr_id     in jobs.mgr_id%type default 30,
        init_id    in jobs.init_id%type,
        sal_id     in jobs.sal_id%type default 100,
        clock_id   in jobs.clock_id%type default 'A',
        shift_id   in jobs.shift_id%type,
        lot_id     in jobs.lot_id%type default 'BACK'
      );
    begin
      myprocedure (job_id     => your_job_id,
                   job_loc    => your_job_loc,
                   mgr_id     => your_mgr_id,
                   init_id    => null,
                   shift_id   => your_shift_id
                  );
    end;
    /
    

    This, however, will NOT WORK, because myprocedure doesn't have a default value declared for init_id

    begin
      myprocedure (job_id     => your_job_id,
                   job_loc    => your_job_loc,
                   mgr_id     => your_mgr_id,
                   shift_id   => your_shift_id
                  );
    end;
    /
    

    Concerning
    Peter

  • Oracle form functions and procedures in the APEX, how?

    I'm working to recreate in the APEX, already existing read only forms in Oracle Forms. Report features interactive APEX among other things, in fact worth as well as to target a different audience than utilizies versions of Oracle Form. Versions of Oracle Forms use a lot of pre and post query triggers, PLSQL functions.

    In Oracle Forms that places, these functions can be found in the "Units of program" section of the form. A feature typical of this kind, based on a particular Mission ID route, collecting names of regular passengers, is shaped with a comma and a space after each of them, in a single string that is returned and displayed the list of passengers of a line.

    I have all of this written code so I can move most of the main request of the Oracle form in an interactive report. These functions and triggers called in the form of the "Units of program" section of the Oracle form rather than stored in the database schema in a package, where they would go inside the APEX? Can I create a 'shortcut' in the APEX and call it from the interactive report "Source Région"? I can create the PLSQL function at the level of the region of the interactive report or page level? Or, my best bet creates a package that is stored in the database, all these functions and/or proecedures I might need the original form of Oracle?

    Some advice would be greatly appreciated.

    RLBickham wrote:
    I don't think I've been pretty clear in the description of the specific thing I want to do, simply, it does not reach the level of forms of conversion of the APEX. It is basically a problem of PLSQL function.

    I have an interactive report which is currently 90 percent of what I want however, each line, which represents a Mission may have several feet. Each arm has two places or ICAO codes attached to it. Based on the number of Mission, I want to loop through the array of leg, collect all the codes of ICAO for this Mission, put them together in 1 variable separated by a coma and add this variable to display the columns in this interactive report as the last column.

    In Oracle Forms, I have a function registered in the database, which is called in the main query. Maybe I ask a question that does not need to be asked, but anyway my question is can I put this function currently in the database somewhere within the interactive report and somehow reference it via Http, or should I just stick with set of functions and procedures in the packages stored in the database and called the conventional way?

    You could switch the function to the database and call it from the report query, but it sounds as if it were superfluous. In the report query using any form of Re: 4. How can I convert rows to columns? is appropriate for your version of the (unspecified) database.

    -----

    When you have a problem, you will get an answer faster, more efficient including information as much information as possible from the outset. This should include:

  • Full version of APEX
  • Complete operating system DB, version, edition, host
  • Architecture of Web server (EPG, SST or APEX listener/host operating system)
  • Browser (s) and version (s) used
  • Theme
  • Model (s)

  • Region/section type (s) (particularly as to distinguish if a 'report' is a standard report, an interactive report, or indeed a 'update report' (i.e. a tabular presentation))

    With APEX, we also had the chance to have a great resource in apex.oracle.com where we can reproduce and share problems. Reproduce things is the best way to solve most of the questions, particularly those relating to the layout and Visual formatting. If you expect a detailed response it is appropriate that you take on an important part of the effort by getting as much as possible with an example of the problem on apex.oracle.com before asking for help on specific issues, then we can see firsthand.

  • Same algorithm in function and procedure so that one will be better?

    Why is better to pl sql function calculates a value instead of the procedure?
    If I apply the same algorithm in function and procedure while one will perform better?

    Siddharth Singh says:
    Oracle documentation

    http://docs.Oracle.com/CD/B10500_01/AppDev.920/a96624/08_subs.htm

    This:

    Generally, you use a procedure to perform an action and a function to calculate a value.

    Does not mean that the function are better to calculate a value, but you usually use functions to calculate a value.

    Usually, a function is can be more useful if you plan to use in a query.
    that is to say:

    SELECT myfunc(col1) from mytable;
    

    That you can't do with a procedure. Functions are also usually limited to the returning a single value, while procedures may have several OUTPUT parameters.

    Kind regards.
    Al

    Published by: Alberto Faenza on 21 November 2012 15:31

  • Functions vs. procedures

    Is it true and convenient than functions (boolean, int, double, etc.) should never change the attributes, or call procedures? (that is, they should only return an attribute or calculate something than to return something).

    Is it true and convenient than functions (boolean, int, double, etc.) should never change the attributes, or call procedures? (that is, they should only return an attribute or calculate something than to return something).

    This principle of goes back to the original Fortran, where functions and procedures were distinct, and the functions were not allowed to have any side effects whatsoever.

    The rule was relaxed quickly when he understood that prevent functions prevents any IO, which makes debugging impossible.

    It was a fifty years ago.

    The rule has no application in Java either.

  • 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.

  • change the functions or procedures under sqlplus

    I have a problem to connect to the database of PL/SQL Developer, but I can connect to sqlplus to UNIX machine. How can I change a function of sqlplus?
    Thank you.

    Hello

    It's a little easier to connect to SQL * as owner and request rather than all_source user_source fucntion.

    To generate the file:

    SET  PAGESIZE  0
    SET  TRIMSPOOL ON
    
    SPOOL  c:\some_path\func_x.sql
    
    SELECT    text
    FROM      user_source
    WHERE     name = 'FUNC_X'     -- or whatever, case-sensitive
    AND       type = 'FUNCTION'   -- or 'PROCEDURE', or 'PACKAGE', or 'PACKAGE BODY', or ...
    ORDER BY  line;
    
    SPOOL  OFF
    

    Use any text editor to edit the file you created.

    The first line of a function begins with "FUNCTION". This must change to say "CREATE or REPLACE the FUNCTION".
    At the end, add these two lines:

    /
    SHOW ERRORS
    

    When you have made any changes, save the file and return in SQL * Plus, say:

    @c:\some_path\func_x.sql
    

    In other words, after the sign @, and put the path of the file with the modified code.

  • functions, the procedure

    whence, functions, triggers, package and procedure are stored after they are created in oracle?

    record of RDBMS?

    How we see them there (function)?

    Hello

    They are stored in the data dictionary.

    To view the source code, you can query user_source, all_source or dba_source, or use the package supplied by Oracle DBMS_METADATA

  • 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.

  • How to write the function or procedure to function 'Round' in oracle

    Hello friends,

    Last week I went to attend the interview. I asked a function, or a procedure to achieve the functionality of the 'Round' function in oracle manually. I couldn't reach it properly. Can someone let me know how I can do this? Is a mathematical idea behind it?

    Thank you and best regards,
    SB

    Hello

    create or replace
    function my_round_fn (p_number in number, number of Round_Val)
    Return number
    is
    whole v_round;
    Start
    v_round: = P_number * Power (10, Round_Val);
    Return v_round / (Power (10, Round_Val));
    end my_round_fn;

    It works in all cases.

    Kind regards
    Praveen

  • execution of function and procedure

    Hi all
    I question in the execution of the procedure and run oracle database feature.
    I want to know what is faster in execution procedure or function.

    can I see the timeframes of proceedings and select request
    I want to see one time not CPU cost or anything else.

    I'm waiting for your answers...

    There is no difference in cost between if something is a function, or a procedure.

    The decision-making process must reflect usage only. For example you can not use a procedure in SQL.

    If you want to break things down to focus more on tracing 10046 and 10053.

    See time only is roughly equivalent to cut all your fingers to see how something is your thumb.
    Timing is only a small part of what you should look at.

  • Call of function/stored procedure of dashboards

    Hi all

    My requirement is to call a stored procedure /function of dashboard and display the result in the dashboard.

    I created a function that takes in 2 dates and restores the lines in this date range

    (1) creation of function

    create or replace FUNCTION FUNC3 (BDATE TIMESTAMP, EDATE TIMESTAMP) return as sys_refcursor
    R1 sys_refcursor;
    BEGIN open for r1
    SELECT * FROM EMP WHERE HIREDATE BETWEEN BDATE AND EDATE.
    Return (R1);
    END;


    (2) created a dashboard quickly start date and the end date and the variable defined as variable presentation 'Pre_B1Date' & 'Pre_E1Date '.

    (3) created a request directly to the database as

    SELECT FUNC3 (to_date (' @{Pre_B1Date} ',' YYYY/MM/DD hh: mi PM'), to_date (' @{Pre_B1Date} ',' YYYY/MM/DD hh: mi PM')) FROM DUAL

    (4) that I've created a dashboard with the above command prompt & demand live, but when I try to open the dashboard why the BI server is blocking down.

    gave me an error

    Error codes: OPR4ONWY:U9IM8TAC:OI2DL65P
    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error occurred. [nQSError: 12002] Communication to the socket call = recv error: (10054 = number) an existing connection has to be closed by the remote host. (HY000)

    Publ. SQL: {call NQSGetQueryColumnInfo (' EXECUTE the PHYSICAL "Con pool Scott" CONNECTION POOL SELECT FUNC3 (to_date ("@{Pre_BDate}","YYYY/MM/DD hh: mi PM"), to_date ("@{Pre_BDate}","YYYY/MM/DD hh: mi PM")) FROM DUAL')}


    have one never faced this problem?

    or is there another way to call a funcation stored dashboards, /procedure
    where you can pass the variables of the presentation and view the output put this /procedure function

    Thank you
    sangov

    Yes.

    You can't return a cursor in a column in a select statement. You must use a piplined function (also known as table function).
    http://gerardnico.com/wiki/language/PLSQL/plsql_pipelined_function

    You'll find yourself with:

    select * from FUNC3(BDATE,EDATE) 
    

    See you soon
    Nico

    Published by: gerardnico on July 31, 2009 11:35 remove the data type in the select

  • all functions and procedures works this way? (dbms_lock)

    Hi guys,.

    throughout, I thought...

    Start
    dbms_output.put_line ('a');
    dbms_output.put_line ('b');
    end;

    When built, I thought of the oracle pl/sql interpreter read the source line by line
    the steps below

    -seen dbms_output.put_line ('a'), print a
    -seen dbms_output.put_line ('b'); ... print b

    That's all...

    but after using dbms_lock, I realize its abit differs from the way I thought...

    Start
    dbms_output.put_line ('a');
    DBMS_LOCK. Sleep (10);
    dbms_output.put_line ('b');
    end;
    /

    I'd actually wait for 10 seconds before I see the result 'a' and 'b '...
    so it seems to me

    the interpreter would be
    (1) see dbms_output.put_line ('a'); -It's going to print 'a' but which is still
    (2) see dbms_lock.sleep (10); -sleep for 10 sec...
    (3) see dmbS_output.put_line ('b') - you know it's going to print 'b', but which is still
    (4) see at the end; -ok print 'a' and 'b '.


    so, somehow, to return the result or printing... He seems to have done until the END of the block/procedure/function instead of intepreting line-by-line and runs it.
    However, for dbms_lock.sleep (10), its seems to be interpreted and executed immediately in the middle of the block.

    so can I conclude that
    for his return / displaying the result, it is done at the end of the block
    for others, it is done during the block

    Am I wrong?

    Best regards
    Noob

    The thought is always a good thing, but read the docs is also useful. PL/SQL unit is still running on the side of server database and always as a unit. written dbms_output.put_line('A') simply has to a buffer and PL/SQL unit continues to run. any unit buffer has all the lines written. Now the client tool, SQL * Plus, in your case, can read the contents of the buffer and display it. SQL * more is it based on the command SET SERVEROUTPUT on / off. I hope now you understand that DBMS_OUTPUT does not provide an interface to display the customer exit, but rather store it in a buffer.

    SY.

Maybe you are looking for

  • Firefox will work on a Warp ZTE?

    Just wondering because I think of her being of Boost Mobile.

  • Portege R200 - works with or without extended desktop

    Jinthe last 2 years I have worked with a provincial court 2010 portege now just bought a portege r200. I already had a problem with dual-view: at the office, I work with office extended Windows on a second monitor.at home, I had only the display port

  • Uninstall app programmatically

    Is it possible to uninstall application bb programmatically?

  • Parts support

    My employer gave me a robust Latitude 14. I want the additional disk capacity using the MSATA slot and ordered them accordingly. In addition, I wanted to swap the hard drive, so I can run a different operating system. Initially, I spent 4 hours waiti

  • How to prevent my organizing EINIRE of Revel catalog synchronization.

    I use the EP 13 Evaluation Version.  I have an iMac 2009 Mavericks 10.9.5 running.  Yesterday, I shared a video test of Revel.  Last night, I checked organiser a little more and had terrible problems.  After that I tried to get the Organizer to acces