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.

Tags: Database

Similar Questions

  • 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

  • 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

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

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

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

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

  • integer_tbl function and procedure

    Hi all

    I have a function that uses ref cursor and integer table.

    FUNCTION gp_long (ID IN integer_tbl, p_start_date IN VARCHAR2, p_end_date IN VARCHAR2)
    RETURN gp_long_cur;

    I understand gp_long_cur is a ref cursor, but not able to understand ID IN integer_tbl.
    If I want to pass parameters in ID integer_tbl how to do this.

    Could someone direct me to a link.

    Thanks in advance

    Rgds
    Saaz

    It depends on how the definition of the integer_tbl.
    If it is defined as

    TYPE integer_tbl IS TABLE OF INTEGER;
    

    Then, you can call your function as for example.

    DECLARE
       c SYS_REFCURSOR;
    BEGIN
       c := gp_long (integer_tbl(1, 2, 42), DATE '2011-01-01', SYSDATE);
    ...
    END;
    

    URS

  • Passage of tables through multiple functions and PL/SQL procedures

    I am now a great application of PL/SQL. There is a main procedure which is initially called who subsequently passes information to other PL/SQL functions and procedures. Ultimately an error code and the string is passed to PUT_LINE so it can be displayed. I want to be able to do is to have a table that stores an error code and a string for every error it then go through each of the procedures and functions. This would mean passing these codes and the strings of a function to a function within the pl/sql application. What would be the best way to implement this and is it possible to move heavy or folders to other PL/SQL functions? Thank you.

    Here is a simulation->

    satyaki>
    satyaki>select * from v$version;
    
    BANNER
    ----------------------------------------------------------------
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
    PL/SQL Release 10.2.0.3.0 - Production
    CORE    10.2.0.3.0      Production
    TNS for 32-bit Windows: Version 10.2.0.3.0 - Production
    NLSRTL Version 10.2.0.3.0 - Production
    
    Elapsed: 00:00:00.20
    satyaki>
    satyaki>
    satyaki>create or replace type n_array is table of number;
      2  /
    
    Type created.
    
    Elapsed: 00:00:07.10
    satyaki>
    satyaki>CREATE OR REPLACE PROCEDURE Get_Array(array_in IN n_array,
      2                                        array_out OUT n_array)
      3  IS
      4  BEGIN
      5    array_out := n_array();
      6    FOR i IN 1..array_in.count
      7    LOOP
      8      array_out.extend;
      9      array_out(i) := array_in(i) * 2;
     10    END LOOP;
     11  END Get_Array;
     12  /
    
    Procedure created.
    
    Elapsed: 00:00:00.89
    satyaki>
    satyaki>
    satyaki>Create or Replace Procedure Set_Array(myArray IN n_array)
      2  is
      3    i   number(10);
      4    rec emp%rowtype;
      5    w n_array:=n_array(1200,3200);
      6    bucket n_array := n_array();
      7  Begin
      8    Get_Array(w,bucket);
      9
     10    for i in 1..myArray.count
     11    loop
     12      select *
     13      into rec
     14      from emp
     15      where empno = myArray(i);
     16      dbms_output.put_line('Employee No:'||rec.empno||' Name:'||rec.ename);
     17      for j in 1..bucket.count
     18      loop
     19        dbms_output.put_line('Commission Sub Type: '||bucket(j));
     20      end loop;
     21    end loop;
     22  End Set_Array;
     23  /
    
    Procedure created.
    
    Elapsed: 00:00:01.33
    satyaki>
    satyaki>
    satyaki>select * from emp;
    
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
    ---------- ---------- --------- ---------- --------- ---------- ---------- ----------
          9999 SATYAKI    SLS             7698 02-NOV-08      55000       3455         10
          7777 SOURAV     SLS                  14-SEP-08      45000       3400         10
          7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
          7566 JONES      MANAGER         7839 02-APR-81       2975                    20
          7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30
          7698 BLAKE      MANAGER         7839 01-MAY-81       2850                    30
          7782 CLARK      MANAGER         7839 09-JUN-81       4450                    10
          7788 SCOTT      ANALYST         7566 19-APR-87       3000                    20
          7839 KING       PRESIDENT            17-NOV-81       7000                    10
          7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30
          7876 ADAMS      CLERK           7788 23-MAY-87       1100                    20
    
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
    ---------- ---------- --------- ---------- --------- ---------- ---------- ----------
          7900 JAMES      CLERK           7698 03-DEC-81        950                    30
          7902 FORD       ANALYST         7566 03-DEC-81       3000                    20
    
    13 rows selected.
    
    Elapsed: 00:00:00.28
    satyaki>
    satyaki>declare
      2    v n_array:=n_array(9999,7777);
      3  begin
      4    Set_Array(v);
      5  end;
      6  /
    Employee No:9999 Name:SATYAKI
    Commission Sub Type: 2400
    Commission Sub Type: 6400
    Employee No:7777 Name:SOURAV
    Commission Sub Type: 2400
    Commission Sub Type: 6400
    
    PL/SQL procedure successfully completed.
    
    Elapsed: 00:00:00.15
    satyaki>
    satyaki>
    

    Kind regards.

    LOULOU.

  • function and packages

    Hi friends,

    I have a requirement where in I need decode my source table values while inserting in my target table. I usually do my task by performing functions (don't use case and decode). My first question is

    (1) is using the function to accomplish these tasks is good. I have several of these conversion requirements.
    (2) Clubbing subprogrammes togther in packages is a good habit. But what should be the number of these subprogrammes. I can club togther 100 of this togther functions (a function of the average is 50 lines)? If this is not the case, what should be the thoughts of segregation?
    (3) are the oracle integrated like sqrt, length etc. deterministic functions?

    This code represents a typical requirement of the mine where in I map my name of source country in the target
    ID of country when migrating my data from the source to the target.

    create table source 
    (
    emp_id number,
    empname varchar2(100),
    sal number,
    country varchar2(100)
    );
    
    
    insert into source values (1,'ALEX',1000,'US');
    Insert into source values (2,'RAHUL',2000,'IND');
    Insert into source values (3,'KARTIK',3000,'IND');
    Insert into source values (4,'SHADOW',5000,'US');
    insert into source values(5,'LOUI',1500,'JAP');
    
    
    Create table source_country_code
    (
    country varchar2(100),
    abbrv  varchar2(100),
    area number,
    climate varchar2(100)
    );
    
    insert into source_country_code values ('UNITED STATES','US',10000,'COLD');
    insert into source_country_code values ('INDIA','IND',100000,'HOT');
    insert into source_country_code values ('JAPAN','JAP',1000000,'MODERATE');
    
    
    
    
    Create table target_country_code
    (
    country_id number,
    descr  varchar2(100),
    density number,
    weather varchar2(100)
    );
    
    insert into target_country_code values (101,'this is descrition txt 1',1001,'COLD');
    insert into target_country_code values (102,'this is descrition txt 2',1001,'HOT');
    insert into target_country_code values (103,'this is descrition txt 3',1001,'MODERATE');
    
    
    
    create table target
    (
    emp_id number,
    empname varchar2(100),
    sal number,
    country_id number
    );
    I generally functions for this kind of mappings. I have several of these requirements as indicated above and the
    cardinality of data is high.
    create or replace function transform (in_src_country varchar2) return number deterministic
    as
    l_country_id number;
    l_climate varchar2(1000);
    begin
    
    select climate into l_climate from source_country_code
       where upper(abbrv)=upper(in_src_country);
       
    select country_id into l_country_id
    from target_country_code
    where upper(weather)=upper(l_climate);
    
    return(l_country_id);
    exception 
    when no_data_found then
    return null;
    end;
    last step,

    so, what I usually do is

    insert into target
    Select emp_id, empname, sal, transform (country) in the source;



    As always, thank you

    Rahul

    Published by: Rahul K on 5 June 2013 10:51

    No technique is universally good or bad universally. You must understand your needs, the compromise and what you're trying to optimize for.

    If you don't care anything else you are looking for the absolute fastest performance, reduce what you have to do in PL/SQL is a good idea. Most of the people and most of the systems, however, prefer to have code that is a bit slower if it makes the code easier to maintain and easier to write or minimizes the number of places that the code is duplicated. If you attempt to load a data warehouse of company with billions of new lines every night, you're as almost exclusively worry about raw performance. And, if you design correctly, there is that one way to load any particular item of data, you don't have to worry about code duplication because there will always be an INSERT statement that inserts data in a particular table. If you build an OLTP application, on the other hand, it is very likely that there will be many places where you want to do something like search for a value and you are much less concerned about raw performance you're on maintainability and ensure that you do not duplicate the code. In these cases, well-designed functions and procedures are well worth the return miners (so if you do a query of single line as most OLTP systems are generally easier to treat if you write DSS queries that return millions of processing lines billionr lines.

    Justin

  • Dependent pages and procedures

    Hi all

    I was put on a project where a table has to be completely redone. the structure of the new table is so completely different from the old.

    Now delete the old table will have repercussions throughout the entire application and the database.

    Is there a way to know which pages, tables, procedures and functions depend on the old table?

    For views, packages, functions and procedures, use dictionary, _DEPENDENCIES views:

  • USER_DEPENDENCIES
  • ALL_DEPENDENCIES
  • DBA_DEPENDENCIES
  • 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.

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

  • 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
    

Maybe you are looking for

  • iTunes won't erase a webloc

    On MacOS 10.11.2, I aimed my browser and inadvertently fall a webloc on my window iTunes 12.3.2.35 file, creating a fake podcast.  Edit > Delete does not delete it, any more than the fn-DELETE, or command + DELETE, or control - delete.  What will be?

  • installed kb2463332 over and over

    Instances of Microsoft SQL Server 2005 Express Edition and components to Service Pack 4 (SP4) KB2463332 installs over and over with any errors. How can I fix this Windows Update?

  • Microsoft Outlook 2007

    Anyone know how to make the calendar in Microsoft Office Outlook 2007, count the number of days in the year? Outlook has already the number of weeks in the year, but I want to count the number of days during which has passed. For example: June 9, 200

  • BlackBerry smartphones add address

    Cannot add address contacts. He telss me he is updated on the outside and is deleted when I throw or cancel > I'm not allowed to save. Any ideas?

  • Player show no information in fill areas

    I downloaded tax Franchise Board California tax forms, them saved on my computer, completed and printed.everything as I always did in the past, but this time something has changed.  The information contained in the forms to fill-able did not print, b