Checking the performance of Pl/SQL Procedure

I have a PL/SQL procedure of 10,000 lines, & I dont have any Tool of performance checking only thing I have is SQL Client & database how whould I check the performance of the procedure

Why do you want to check the performance? Have you indentified a specific problem?
It is not easy to to "simply check the performance" of code. Let's say it has an elapsed execution time of 90 seconds. What does that tell you? Fast? Slow? Average? What does 90 seconds tell you about the resource utilisation? Nothing much - are resources being red lined for those 90 seconds or not?
So unless there is a specific performance problem that has been diagnosed, e.g. the process uses too much PGA memory, you cannot really identify a performance problem.
What you can do is use DBMS_PROFILE (Oracle supplied PL/SQL package) to profile the execution time of the code. This will tell you which pieces of the code are slower than others. This allows you to focus on area where possible optimisation can reduce overall execution time - or it could be that these areas are already optimised.
What you can miss with this approach is a small loop that takes a few seconds to execute - less than 1% of the total elapsed execution time. But this loop can be very wrong and should have taken a few millisecs to do. A month later running against big production data volumes, this loop's runtime changes into minutes and over 50% of the overall execution time of the process.
You may look at the FOR CURSOR FETCH loop and see that it has been optimised. Great, so you move on to look at the next piece of code. Only, there are other loop constructs that can be exponentially faster than this loop - like a bulk processing loop instead.
You may look at a SQL that seems slow, but after investigation it seems to be optimal. And it could well be. But performance can be increased by 80% by not touching the SQL and instead changing the table's structure from a normal heap table to a ranged partitioned table.
The bottom line is that there are no magic wands and crystal balls that can be used to check performance and tell you that "abc" is wrong. Tools can tell you what is slow, what is resource expensive - but it cannot tell you whether the code does what it is suppose to do in the best and most effective way. Only a programmer can. Which means that things like code reviews, design walk-thru's and so on, are critical pieces to ensure that the code is performant and can scale.

Similar Messages

  • How to check the performance of a computer.

    Dear all,
    how can i check the performance of a computer.
    i write a procedure which insert values in a table. when i execute the procedure it goes hang for a long time and after insertion it give the message the procedure completed successfully.
    but how to show the time of the execution of the procedure.
    my procedure is here.
    procedure test_proc
    is
    no_gen number :=0;
    begin
    loop
         insert into voucherh
         values (test_sq.nextval, sysdate, 'JV', 'Muhammad Nadeem', 'Muhammad Omer Ghauri', 'Sheraz Ayyub', 'Muntazir Mehdi');
         commit;
         no_gen := no_gen +1;
         exit when no_gen = 100000;
    end loop;
    END test_proc;
    thanks
    Muhammad Nadeem
    CHIMERA PVT. LTD.
    LAHORE
    [email protected]
    0301-8334434

    Here is a more elaborated function that returns the difference in day/hour/minute/seconds
    CREATE OR REPLACE FUNCTION Diff_Temps
         LD$Date_Deb IN DATE DEFAULT SYSDATE
         ,LD$Date_Fin IN DATE DEFAULT SYSDATE
         ,LN$JJ       OUT PLS_INTEGER
         ,LN$HH       OUT PLS_INTEGER
         ,LN$MI       OUT PLS_INTEGER
         ,LN$SS       OUT PLS_INTEGER
      ) Return NUMBER
    IS
      dif   NUMBER ;
    Begin
      If LD$Date_Fin < LD$Date_Deb Then
         Return ( -1 ) ;
      End if ;
      Select  LD$Date_Fin - LD$Date_Deb Into dif  From DUAL ;
      Select  trunc ( LD$Date_Fin - LD$Date_Deb)  Into LN$JJ  From DUAL ;
      Select  trunc ( (LD$Date_Fin - LD$Date_Deb) * 24) -  ( LN$JJ * 24 ) Into LN$HH From DUAL ;
      Select  trunc ( (LD$Date_Fin - LD$Date_Deb) * 1440) - ( (LN$HH * 60) + ( LN$JJ * 1440) ) Into LN$MI From DUAL ;
      Select  trunc ( (LD$Date_Fin - LD$Date_Deb) * 86400) - ( (LN$MI * 60) + (LN$HH * 3600) + ( LN$JJ * 3600 * 24 ) ) Into LN$SS From DUAL ;
      Return( dif ) ;
    End ;
    /That you can call as follow:
    SQL> set serveroutput on
    SQL> declare
      2   dd pls_integer;
      3   hh pls_integer;
      4   mi pls_integer;
      5   ss pls_integer;
      6   dif number ;
      7  Begin
      8   dif := diff_temps ( sysdate, sysdate + 10.523, dd,hh,mi,ss ) ;
      9   dbms_output.put_line(
    10     '(' || ltrim(to_char(dif,'99999.99999')) || ')' || '  '
    11     || to_char(dd,'99999') || 'j '
    12     || to_char(hh,'00') ||':'
    13     || to_char(mi,'00') ||':'
    14     || to_char(ss,'00')
    15     ) ;
    16  End;
    17  /
    (10.52300)      10j  12: 33: 07Francois

  • How to check the performance of a report

    plz tell me all the ways to check the performance of a report
    if u send me the step wise then it will be really helpful to me
    awaiting for u r reply

    I. Non Database Performance
    Dead Code (Program -> Check -> Extended Prog. Check) - unused subroutines appear as warnings under PERFORM/FORM interfaces. - unused variables appear as warnings under Field attributes. Transaction code is SLIN. This will also catch literals (section III below).
    When possible use MOVE instead of MOVE-CORRESPONDING (move bseg to *bseg or move t_prps[] to t_prps2[] if you want to copy entire table or t_prps to t_prps2 if you only want to copy header line.)
    Code executed more than once should be placed in a form routine.
    SORT and READ TABLE t_tab WITH KEY ... BINARY SEARCH when possible especially against non-buffered table (Data Dictionary -> Technical Info)
    SORT tables BY fields
    Avoid unnecessary moves to table header areas.
    Subroutine parameters should be typed for efficiency and to help prevent coding and runtime errors.
    II. Database Performanc
    Avoid ORDER BY unless there is index on the columns - sort internal table instead
    SELECT SINGLE when possible
    SELECT fields FROM database table INTO TABLE t_tab (an internal table) - Lengthy discussion.
    Views (inner join) are a fast way to access information from multiple tables. Be aware that the result set only includes rows that appear in both tables.
    Use subqueries when possible.
    "FOR ALL ENTRIES IN..." (outer join) are very fast but keep in the mind the special features and 3 pitfalls of using it.
    (a) Duplicates are removed from the answer set as if you had specified "SELECT DISTINCT"... So unless you intend for duplicates to be deleted include the unique key of the detail line items in your select statement. In the data dictionary (SE11) the fields belonging to the unique key are marked with an "X" in the key column.
    (b) If the "one" table (the table that appears in the clause FOR ALL ENTRIES IN) is empty, all rows in the "many" table (the table that appears in the SELECT INTO clause ) are selected. Therefore make sure you check that the "one" table has rows before issuing a select with the "FOR ALL ENTRIES IN..." clause.
    (c) If the 'one' table (the table that appears in the clause FOR ALL ENTRIES IN) is very large there is performance degradation Steven Buttiglieri created sample code to illustrate this.
    Where clause should be in order of index See example.
    This is important when there are multiple indexes for a table and you want to make sure a specific index is used. This will change when we convert from a "rules based" Oracle optimizer to a "cost based" Oracle optimizer. You should be aware of a bug in Oracle, lovingly referred to as the "3rd Column Blues". Click here for more information on indexes.
    Where clause should contain key fields in an appropriate db index or buffered tables. As long as we are using the Oracle Cost Based Optimizer, be aware fo the "Third Column Blues", an Oracle bug.
    Avoid nested SELECTs (SELECT...ENDSELECT within another SELECT...ENDSELECT). Load data in internal tables instead. See item 3 above.
    Use SQL statistical functions when possible (max, sum, ...)
    Delete all rows from a table. A where clause is mandatory. Specifying the client is the most efficient way.
    Put Check statements into where clause - caveat: Make sure that the index is still being used after you add the additional selection criteria. If the select statement goes from using an index to doing a db scan (reading each row in the database without going through an index) get it out of the where clause and go back to using "Check"!
    III. Literals
    Codes ('MD') should use contants (c_medical)
    Longer text should use text elements. Sample code is a good example because it uses the text element in conjunction with the hard coded text. This documents the text element and provides for the possibility of multi-language support.
    IV. Miscellaneous
    Use CASE statement instead of IF...ELSEIF when possible (It is only possible in equality tests)
    Nested If - encounter most likely to fail first (specific to general)
    And - encounter most likely to fail first (specific to general)
    OR's - encounter most likely to succeed first (general to specific)
    Variables should use Like when possible
    Subroutine usage - don't place decision to execute in the subroutine
    If not ( t_prps[] is initial ) (instead of describe table t_prps lines sy-tfill, if sy-tfill > 0...)
    New document types confirmed with the configuration team via MIT-ABAP mail list prior to coding a report to access the data.
    Dates need to be properly formatted using the user's default settings. For the explanation of the BDC example check out the developer's standards.
    regards,
    suryaprakash.

  • How to check the performance of the database instance in oracle apps 11i

    hii everybody,
    i want to know,how to check the performance of the database instance using oracle applications 11i.your help highly appreciated,thanks.

    Pl do not post duplicates - how to check the performance of the server in oracle applications 11i

  • Check the validity of a SQL statement before execution

    Hi everyone,
    In an applet I have created, I am allowing the user to create a SQL statement which will be sent to a servlet that in turn issues the JDBC request for the SQL statement. My concern is that since my GUI lets the user create more or less any kind of SQL statement (including an illegal one) I need to verify if the user has created the correct SQL. How can this be achieved?
    To recapitulate and summarize, I need to know how I can check the validity of a SQL statement without actually executing it and handling the SQLException. FYI, I am using the mm-mysql driver.
    Thanks,
    Alan

    jschell is correct. Unless you're writing something like an ISQL tool you want to be very careful doing this.
    Having said that Mimer SQL have SQL validators that may do what you want http://developer.mimer.com/validator/index.htm
    They've also got the SQL Validator running as a web service that you can use. Theres example code here showing how to use it.
    http://sqlvalidator.mimer.com/index.html
    At the risk of being accused of selfpromotion you can check out the SQL Validator plugin for SQuirreL SQL CLient. This is a fully functional example of using the Mimer SQL Validation web service. http://squirrel-sql.sourceforge.net/
    Col

  • How to check the performance of the server in oracle applications 11i

    hii everybody,
    i want to know,how to check the performance of the system(test server) using oracle applications 11i.your help highly appreciated,thanks.

    938946 wrote:
    hii everybody,
    i want to know,how to check the performance of the system(test server) using oracle applications 11i.your help highly appreciated,thanks.Please see old threads for the same topic/discussion -- https://forums.oracle.com/forums/search.jspa?threadID=&q=Performance+AND+Tuning&objID=c3&dateRange=all&userID=&numResults=15&rankBy=10001
    Thanks,
    Hussein

  • How to check  the performance of process chain.

    Hi experts,
    Can any one suggest me the process how to check the performance of the process chain in a graphical presentation (need detailed info on this)??
    Thanks in advance.

    Have a look ath this:
    Process Chains Performance
    Hope it helps.
    Regards

  • How to open report in the browser from PL/SQL procedure

    Hi,
    I need to call the report (with destype = SCREEN) from the PL/SQL procedure and display in the browser.
    For Example: when I call P_call_report procedure in my Forms6i button or at sql*plus, the report output PDF/HTML should open in the Browser window.
    Iam Using IE, report6i, forms 6i, Oracle 8.1.7, Windows OS
    I tried using UTL_HTTP(' ') in a procedure. But when I execute the procedure at sql*plus it says Pl/sql procedure completed successfully message without opening report output in the browser window. If I copy the same url and paste it in the browser, it works.
    Please let me know if there is any solution.
    thanks alot.

    I guess event driven publishing may work. But Iam not sure about the opening of the browser from inside the procedure.

  • How to measure the performance of a SQL query?

    Hello,
    I want to measure the performance of a group of SQL queries to compare them, but i don't know how to do it.
    Is there any application to do it?
    Thanks.

    You can use STATSPACK (in 10g its called as AWR - Automatic Workload Repository)
    Statspack -> A set of SQL, PL/SQL, and SQL*Plus scripts that allow the collection, automation, storage, and viewing of performance data. This feature has been replaced by the Automatic Workload Repository.
    Automatic Workload Repository - Collects, processes, and maintains performance statistics for problem detection and self-tuning purposes
    Oracle Database Performance Tuning Guide - Automatic Workload Repository
    http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14211/autostat.htm#PFGRF02601
    or
    you can use EXPLAIN PLAN
    EXPLAIN PLAN -> A SQL statement that enables examination of the execution plan chosen by the optimizer for DML statements. EXPLAIN PLAN causes the optimizer to choose an execution plan and then to put data describing the plan into a database table.
    Oracle Database Performance Tuning Guide - Using EXPLAIN PLAN
    http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14211/ex_plan.htm#PFGRF009
    Oracle Database SQL Reference - EXPLAIN PLAN
    http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_9010.htm#sthref8881

  • How to check the datfiles from oracle SQL Developer(enterprise Manager)

    hi,
    Iam using Oracle SQL Developer as enterprise manager in my local pc.I want to check the size of datafiles using this enterprise manager.could u pls help me out..
    Thanks in advance ,
    R.Ratheesh

    What?
    Sql developer is not enterprise manager.
    Size of datafiles? Read the documention, and read the concepts and administration manuals for your release.
    I am not going to provide links, because you have not given your database version number and secondly if you found this forum you can find the docs.
    But I will give you a clue....DBA_DATA_FILES...
    Message was edited by:
    bazzza

  • Does as3.0 can check the performance of computer

    I want to check the client cpu in flex,to make the client to
    know if the computer can run the application.
    any ideas,thank you!

    See
    http://blog.flexexamples.com/about-you/

  • Check the date of last modified procedure

    Hi,
    could you please tell me how to check last modified function or procedure.
    for example: INVO_75.PCK.PrintInvoices_fct
    Thanks in advance.

    891933 wrote:
    could you please tell me how to check last modified function or procedure.Well, depends on what you mean by modified. In any case, use LAST_DDL_TIME column in DBA/ALL/USER_OBJECTS:
    SQL> create or replace
      2    procedure p1
      3      is
      4      begin
      5          null;
      6  end;
      7  /
    Procedure created.
    SQL> select  to_char(created,'mm/dd/yyyy hh24:mi:ss'),
      2          to_char(last_ddl_time,'mm/dd/yyyy hh24:mi:ss')
      3    from  user_objects
      4    where object_name = 'P1'
      5  /
    TO_CHAR(CREATED,'MM TO_CHAR(LAST_DDL_TI
    10/17/2012 10:55:57 10/17/2012 10:55:57
    SQL> create or replace
      2    procedure p1
      3      is
      4      begin
      5          null;
      6  end;
      7  /
    Procedure created.
    SQL> select  to_char(created,'mm/dd/yyyy hh24:mi:ss'),
      2          to_char(last_ddl_time,'mm/dd/yyyy hh24:mi:ss')
      3    from  user_objects
      4    where object_name = 'P1'
      5  /
    TO_CHAR(CREATED,'MM TO_CHAR(LAST_DDL_TI
    10/17/2012 10:55:57 10/17/2012 10:55:57
    SQL> create or replace
      2    procedure p1
      3      is
      4      begin
      5  null;
      6  end;
      7  /
    Procedure created.
    SQL> select  to_char(created,'mm/dd/yyyy hh24:mi:ss'),
      2          to_char(last_ddl_time,'mm/dd/yyyy hh24:mi:ss')
      3    from  user_objects
      4    where object_name = 'P1'
      5  /
    TO_CHAR(CREATED,'MM TO_CHAR(LAST_DDL_TI
    10/17/2012 10:55:57 10/17/2012 10:56:28
    SQL> Keep in mind, LAST_DDL_TIME didn't change when I issued CREATE OR REPLACE without any actual changes in procedure body. And, by actual changes I mean at least one character in procedure body is different from original. In the above example the only difference is there are no spaces in line
    null;SY.

  • Check the hints used in SQL Query (Parallel, First_Rows)

    Hi,
    I have used above hints in my sql query and found no difference in execution time.
    I just want to know whether the hints are used in my sql are not.
    Could you please let me know where to check for it.
    Thanks in advance

    Can you post the SQL which uses these hints and the execution plan with and without those hints here? Then only community can help you find out if the hints are really used or not.
    Please use code tags to preserve the format of execution plan.
    Edited by: Satish Kandi on Jun 23, 2009 5:37 PM

  • Slow Performance of PL/SQL procedure

    Hi, I'm new in PL/SQL. I had wrote a procedure which extract data from a table and write to a text file. However, I found that this procedure took a long time to return the result. Is that anything wrong with my codes? Here is the codes, please advice.
    CREATE OR REPLACE PROCEDURE DataExtract
    (P_FILEDIR IN VARCHAR2, P_FILENAME IN VARCHAR2)
    IS
    V_FILEHANDLE UTL_FILE.FILE_TYPE;
    V_PRO_DT NUMBER(08);
    V_REC_TYPE CHAR(01);
    TYPE CUST_REC_TYPE IS RECORD
    P_CUST_ID CUSTOMER.CUST_ID%TYPE,
    P_NAME CUSTOMER.NAME%TYPE,
    P_MARR_STAT CUSTOMER.MARR_STAT%TYPE,
    P_HOME_ADDR1 CUSTOMER.HOME_ADDR1%TYPE,
    P_HOME_ADDR2 CUSTOMER.HOME_ADDR2%TYPE,
    P_HOME_ADDR3 CUSTOMER.HOME_ADDR3%TYPE,
    P_HOME_PST_CDE CUSTOMER.HOME_PST_CDE%TYPE,
    P_HOME_PH CUSTOMER.HOME_PH%TYPE,
    P_OFF_ADDR1 CUSTOMER.OFF_ADDR1%TYPE,
    P_OFF_ADDR2 CUSTOMER.OFF_ADDR2%TYPE,
    P_OFF_ADDR3 CUSTOMER.OFF_ADDR3%TYPE,
    P_OFF_PST_CDE CUSTOMER.OFF_PST_CDE%TYPE,
    P_OFF_PH CUSTOMER.OFF_PH1%TYPE,
    CUST_REC CUST_REC_TYPE;
    CURSOR SEARCH_CUSTOMER IS
    SELECT
    CRE_TM,
    UPD_TM,
    CUST_ID,
    NAME,
    MARR_STAT,
    HOME_ADDR1,
    HOME_ADDR2,
    HOME_ADDR3,
    HOME_PST_CDE,
    HOME_PH,
    OFF_ADDR1,
    OFF_ADDR2,
    OFF_ADDR3,
    OFF_PST_CDE,
    OFF_PH
    FROM CUSTOMER
    WHERE SUBSTR(UPD_TM,1,8)
    = V_PRO_DT;
    BEGIN
    SELECT PRO_DT
    INTO V_PRO_DT
    FROM PROCESS_TBL;
    IF SQL%NOTFOUND THEN
    DBMS_OUTPUT.PUT_LINE('NOT FOUND IN PROCESS_TBL');
    END IF;
    V_FILEHANDLE := UTL_FILE.FOPEN (P_FILEDIR, P_FILENAME, 'w');
    WX_REC_TYPE := 'H';
    UTL_FILE.PUTF (V_FILEHANDLE, '%s', V_REC_TYPE);
    UTL_FILE.PUTF (V_FILEHANDLE, '%s', V_PRO_DT);
    UTL_FILE.NEW_LINE (V_FILEHANDLE);
    OPEN SEARCH_CUSTOMER;
    LOOP
    FETCH SEARCH_CUSTOMER INTO
    CUST_REC.V_CRE_TM,
    CUST_REC.V_UPD_TM,
    CUST_REC.V_CUST_NO,
    CUST_REC.V_NAME,
    CUST_REC.V_MARR_STAT,
    CUST_REC.V_HOME_ADDR1,
    CUST_REC.V_HOME_ADDR2,
    CUST_REC.V_HOME_ADDR3,
    CUST_REC.V_HOME_PST_CDE,
    CUST_REC.V_HOME_PH,
    CUST_REC.V_OFF_ADDR1,
    CUST_REC.V_OFF_ADDR2,
    CUST_REC.V_OFF_ADDR3,
    CUST_REC.V_OFF_PST_CDE,
    CUST_REC.V_OFF_PH;
    IF SEARCH_CUSTOMER%NOTFOUND THEN
    EXIT;
    END IF;
    IF SUBSTR(CUST_REC.V_CRE_TM,1,8) = V_PRO_DT THEN
    V_REC_TYPE := 'A';
    ELSE
    V_REC_TYPE := 'U';
    END IF;
    UTL_FILE.PUTF (V_FILEHANDLE, '%s', V_REC_TYPE);
    UTL_FILE.PUTF (V_FILEHANDLE, '%s', CUST_REC.V_CUST_NO);
    UTL_FILE.PUTF (V_FILEHANDLE, '%s', CUST_REC.V_NAME);
    UTL_FILE.PUTF (V_FILEHANDLE, '%s', CUST_REC.V_MARR_STAT);
    UTL_FILE.PUTF (V_FILEHANDLE, '%s', CUST_REC.V_HOME_ADDR1);
    UTL_FILE.PUTF (V_FILEHANDLE, '%s', CUST_REC.V_HOME_ADDR2);
    UTL_FILE.PUTF (V_FILEHANDLE, '%s', CUST_REC.V_HOME_ADDR3);
    UTL_FILE.PUTF (V_FILEHANDLE, '%s', CUST_REC.V_HOME_PST_CDE);
    UTL_FILE.PUTF (V_FILEHANDLE, '%s', CUST_REC.V_HOME_PH);
    UTL_FILE.PUTF (V_FILEHANDLE, '%s', CUST_REC.V_OFF_ADDR1);
    UTL_FILE.PUTF (V_FILEHANDLE, '%s', CUST_REC.V_OFF_ADDR2);
    UTL_FILE.PUTF (V_FILEHANDLE, '%s', CUST_REC.V_OFF_ADDR3);
    UTL_FILE.PUTF (V_FILEHANDLE, '%s', CUST_REC.V_OFF_PST_CDE);
    UTL_FILE.PUTF (V_FILEHANDLE, '%s', CUST_REC.V_OFF_PH);
    UTL_FILE.NEW_LINE (V_FILEHANDLE);
    END LOOP;
    CLOSE SEARCH_CUSTOMER;
    UTL_FILE.FCLOSE (V_FILEHANDLE);
    EXCEPTION
    WHEN UTL_FILE.INVALID_FILEHANDLE THEN
    RAISE_APPLICATION_ERROR (-20001, 'Invalid File.');
    WHEN UTL_FILE.WRITE_ERROR THEN
    RAISE_APPLICATION_ERROR (-20002, 'Unable to write to file.');
    END;
    /

    Hi, I'm new in PL/SQL. I had wrote a procedure which extract data from a table and write to a text file. However, I found that this procedure took a long time to return the result. Is that anything wrong with my codes? Here is the codes, please advice.
    CREATE OR REPLACE PROCEDURE DataExtract
    (P_FILEDIR IN VARCHAR2, P_FILENAME IN VARCHAR2)
    IS
    V_FILEHANDLE UTL_FILE.FILE_TYPE;
    V_PRO_DT NUMBER(08);
    V_REC_TYPE CHAR(01);
    TYPE CUST_REC_TYPE IS RECORD
    P_CUST_ID CUSTOMER.CUST_ID%TYPE,
    P_NAME CUSTOMER.NAME%TYPE,
    P_MARR_STAT CUSTOMER.MARR_STAT%TYPE,
    P_HOME_ADDR1 CUSTOMER.HOME_ADDR1%TYPE,
    P_HOME_ADDR2 CUSTOMER.HOME_ADDR2%TYPE,
    P_HOME_ADDR3 CUSTOMER.HOME_ADDR3%TYPE,
    P_HOME_PST_CDE CUSTOMER.HOME_PST_CDE%TYPE,
    P_HOME_PH CUSTOMER.HOME_PH%TYPE,
    P_OFF_ADDR1 CUSTOMER.OFF_ADDR1%TYPE,
    P_OFF_ADDR2 CUSTOMER.OFF_ADDR2%TYPE,
    P_OFF_ADDR3 CUSTOMER.OFF_ADDR3%TYPE,
    P_OFF_PST_CDE CUSTOMER.OFF_PST_CDE%TYPE,
    P_OFF_PH CUSTOMER.OFF_PH1%TYPE,
    CUST_REC CUST_REC_TYPE;
    CURSOR SEARCH_CUSTOMER IS
    SELECT
    CRE_TM,
    UPD_TM,
    CUST_ID,
    NAME,
    MARR_STAT,
    HOME_ADDR1,
    HOME_ADDR2,
    HOME_ADDR3,
    HOME_PST_CDE,
    HOME_PH,
    OFF_ADDR1,
    OFF_ADDR2,
    OFF_ADDR3,
    OFF_PST_CDE,
    OFF_PH
    FROM CUSTOMER
    WHERE SUBSTR(UPD_TM,1,8)
    = V_PRO_DT;
    BEGIN
    SELECT PRO_DT
    INTO V_PRO_DT
    FROM PROCESS_TBL;
    IF SQL%NOTFOUND THEN
    DBMS_OUTPUT.PUT_LINE('NOT FOUND IN PROCESS_TBL');
    END IF;
    V_FILEHANDLE := UTL_FILE.FOPEN (P_FILEDIR, P_FILENAME, 'w');
    WX_REC_TYPE := 'H';
    UTL_FILE.PUTF (V_FILEHANDLE, '%s', V_REC_TYPE);
    UTL_FILE.PUTF (V_FILEHANDLE, '%s', V_PRO_DT);
    UTL_FILE.NEW_LINE (V_FILEHANDLE);
    OPEN SEARCH_CUSTOMER;
    LOOP
    FETCH SEARCH_CUSTOMER INTO
    CUST_REC.V_CRE_TM,
    CUST_REC.V_UPD_TM,
    CUST_REC.V_CUST_NO,
    CUST_REC.V_NAME,
    CUST_REC.V_MARR_STAT,
    CUST_REC.V_HOME_ADDR1,
    CUST_REC.V_HOME_ADDR2,
    CUST_REC.V_HOME_ADDR3,
    CUST_REC.V_HOME_PST_CDE,
    CUST_REC.V_HOME_PH,
    CUST_REC.V_OFF_ADDR1,
    CUST_REC.V_OFF_ADDR2,
    CUST_REC.V_OFF_ADDR3,
    CUST_REC.V_OFF_PST_CDE,
    CUST_REC.V_OFF_PH;
    IF SEARCH_CUSTOMER%NOTFOUND THEN
    EXIT;
    END IF;
    IF SUBSTR(CUST_REC.V_CRE_TM,1,8) = V_PRO_DT THEN
    V_REC_TYPE := 'A';
    ELSE
    V_REC_TYPE := 'U';
    END IF;
    UTL_FILE.PUTF (V_FILEHANDLE, '%s', V_REC_TYPE);
    UTL_FILE.PUTF (V_FILEHANDLE, '%s', CUST_REC.V_CUST_NO);
    UTL_FILE.PUTF (V_FILEHANDLE, '%s', CUST_REC.V_NAME);
    UTL_FILE.PUTF (V_FILEHANDLE, '%s', CUST_REC.V_MARR_STAT);
    UTL_FILE.PUTF (V_FILEHANDLE, '%s', CUST_REC.V_HOME_ADDR1);
    UTL_FILE.PUTF (V_FILEHANDLE, '%s', CUST_REC.V_HOME_ADDR2);
    UTL_FILE.PUTF (V_FILEHANDLE, '%s', CUST_REC.V_HOME_ADDR3);
    UTL_FILE.PUTF (V_FILEHANDLE, '%s', CUST_REC.V_HOME_PST_CDE);
    UTL_FILE.PUTF (V_FILEHANDLE, '%s', CUST_REC.V_HOME_PH);
    UTL_FILE.PUTF (V_FILEHANDLE, '%s', CUST_REC.V_OFF_ADDR1);
    UTL_FILE.PUTF (V_FILEHANDLE, '%s', CUST_REC.V_OFF_ADDR2);
    UTL_FILE.PUTF (V_FILEHANDLE, '%s', CUST_REC.V_OFF_ADDR3);
    UTL_FILE.PUTF (V_FILEHANDLE, '%s', CUST_REC.V_OFF_PST_CDE);
    UTL_FILE.PUTF (V_FILEHANDLE, '%s', CUST_REC.V_OFF_PH);
    UTL_FILE.NEW_LINE (V_FILEHANDLE);
    END LOOP;
    CLOSE SEARCH_CUSTOMER;
    UTL_FILE.FCLOSE (V_FILEHANDLE);
    EXCEPTION
    WHEN UTL_FILE.INVALID_FILEHANDLE THEN
    RAISE_APPLICATION_ERROR (-20001, 'Invalid File.');
    WHEN UTL_FILE.WRITE_ERROR THEN
    RAISE_APPLICATION_ERROR (-20002, 'Unable to write to file.');
    END;
    /

  • How to tune the performance of Oracle SQL/XML query?

    Hi all,
    I am running Oracle 9i and like to run the following Oracle SQL/XML query. It takes about 3+ hour and still not finish. If I get rid all the XML stuffs it only take minutes to run. Does anybody know how to what's the reason of this slow and how to tune it?
    SELECT XMLElement("CUSTOMER",
    XMLForest(C_CUSTKEY "C_CUSTKEY", C_NAME "C_NAME", C_ADDRESS "C_ADDRESS", C_PHONE "C_PHONE", C_MKTSEGMENT "C_MKTSEGMENT", C_COMMENT "C_COMMENT"),
    (SELECT XMLAgg(XMLElement("ORDERS",
    XMLForest(O_ORDERKEY "O_ORDERKEY", O_CUSTKEY "O_CUSTKEY", O_ORDERSTATUS "O_ORDERSTATUS", O_ORDERPRIORITY "O_ORDERPRIORITY", O_CLERK "O_CLERK", O_COMMENT "O_COMMENT"),
    (SELECT XMLAgg(XMLElement("LINEITEM",
    XMLForest(L_ORDERKEY "L_ORDERKEY", L_RETURNFLAG "L_RETURNFLAG", L_LINESTATUS "L_LINESTATUS", L_SHIPINSTRUCT "L_SHIPINSTRUCT", L_SHIPMODE "L_SHIPMODE", L_COMMENT "L_COMMENT")
    FROM LINEITEM
    WHERE LINEITEM.L_ORDERKEY = ORDERS.O_ORDERKEY)
    FROM ORDERS
    WHERE ORDERS.O_CUSTKEY = CUSTOMER.C_CUSTKEY)
    FROM CUSTOMER ;
    Thanks very much in advance for your time,
    Jinghao Liu

    ajallen wrote:
    Why not something more like
    SELECT *
    FROM fact1 l,
    FULL OUTER JOIN fact1 d
    ON l.company = d.company
    AND l.transactiontypeid = 1
    AND d.transactiontypeid = 2;
    Because this is not an equivalent of the original query.
    drop table t1 cascade constraints purge;
    drop table t2 cascade constraints purge;
    create table t1 as select rownum t1_id from dual connect by level <= 5;
    create table t2 as select rownum+2 t2_id from dual connect by level <= 5;
    select * from (select * from t1 where t1_id > 2) t1 full outer join t2 on (t1_id = t2_id);
    select * from t1 full outer join t2 on (t1_id = t2_id and t1_id > 2);
         T1_ID      T2_ID
             3          3
             4          4
             5          5
                        6
                        7
         T1_ID      T2_ID
             1
             2
             3          3
             4          4
             5          5
                        6
                        7

Maybe you are looking for

  • How do I print email from android Samsung Galaxy 3?

    CANNOT ABLE TO PRINT FROM HP M1005 THOUGH SAMSUNG GALAXY S3 BY OTG CALE.

  • App submission problem

    i get this message when i click"app submission": You do not have access to this resource based on your membership. Access to technical resources such as pre-release software and associated documentation, and information related to distributing iOS or

  • SSRS reports in text format

    hi how can i save a report in text format using ssrs 2008 R2

  • Large File Support OEL 5.8 x86 64 bit

    All, I have downloaded some software from OTN and would like to combine the individual zip files into one large file. I assumed that I would unzip the individual files and then create a single zip file. However, my OEL zip utility fails with the file

  • How do i get photos back

    Basically I deleted some pictures on my phone by accident. They ment so much too me! Is there any way of getting them back?