Need to increase performance-bulk collect in cursor with limit and in the for loop inserting into the trigger table

Hi all,
I have a performance issue in the below code,where i am trying to insert the data from table_stg into target_tab and in parent_tab tables and then to child tables via cursor with bulk collect .the target_tab and parent_tab are huge tables and have a row wise trigger enabled on it .the trigger is mandatory . This timetaken for this block to execute is 5000 seconds.Now my requirement is to reduce it to 5 to 10 mins.
can someone please guide me here.Its bit urgent .Awaiting for your response.
declare
vmax_Value NUMBER(5);
  vcnt number(10);
  id_val number(20);
  pc_id number(15);
  vtable_nm VARCHAR2(100);
  vstep_no  VARCHAR2(10);
  vsql_code VARCHAR2(10);
  vsql_errm varchar2(200);
  vtarget_starttime timestamp;
  limit_in number :=10000;
  idx           number(10);
          cursor stg_cursor is
         select
               DESCRIPTION,
               SORT_CODE,
               ACCOUNT_NUMBER,
                 to_number(to_char(CORRESPONDENCE_DATE,'DD')) crr_day,
                 to_char(CORRESPONDENCE_DATE,'MONTH') crr_month,
                 to_number(substr(to_char(CORRESPONDENCE_DATE,'DD-MON-YYYY'),8,4)) crr_year,
               PARTY_ID,
               GUID,
               PAPERLESS_REF_IND,
               PRODUCT_TYPE,
               PRODUCT_BRAND,
               PRODUCT_HELD_ID,
               NOTIFICATION_PREF,
               UNREAD_CORRES_PERIOD,
               EMAIL_ID,
               MOBILE_NUMBER,
               TITLE,
               SURNAME,
               POSTCODE,
               EVENT_TYPE,
               PRIORITY_IND,
               SUBJECT,
               EXT_PRD_ID_TX,
               EXT_PRD_HLD_ID_TX,
               EXT_SYS_ID,
               EXT_PTY_ID_TX,
               ACCOUNT_TYPE_CD,
               COM_PFR_TYP_TX,
               COM_PFR_OPT_TX,
               COM_PFR_RSN_CD
         from  table_stg;
type rec_type is table of stg_rec_type index by pls_integer;
v_rt_all_cols rec_type;
BEGIN
  vstep_no   := '0';
  vmax_value := 0;
  vtarget_starttime := systimestamp;
  id_val    := 0;
  pc_id     := 0;
  success_flag := 0;
          vstep_no  := '1';
          vtable_nm := 'before cursor';
    OPEN stg_cursor;
          vstep_no  := '2';
          vtable_nm := 'After cursor';
   LOOP
          vstep_no  := '3';
          vtable_nm := 'before fetch';
--loop
    FETCH stg_cursor BULK COLLECT INTO v_rt_all_cols LIMIT limit_in;
              vstep_no  := '4';
              vtable_nm := 'after fetch';
--EXIT WHEN v_rt_all_cols.COUNT = 0;
    EXIT WHEN stg_cursor%NOTFOUND;
FOR i IN 1 .. v_rt_all_cols.COUNT
  LOOP
   dbms_output.put_line(upper(v_rt_all_cols(i).event_type));
    if (upper(v_rt_all_cols(i).event_type) = upper('System_enforced')) then
              vstep_no  := '4.1';
              vtable_nm := 'before seq sel';
          select PC_SEQ.nextval into pc_id from dual;
              vstep_no  := '4.2';
              vtable_nm := 'before insert corres';
          INSERT INTO target1_tab
                       (ID,
                        PARTY_ID,
                        PRODUCT_BRAND,
                        SORT_CODE,
                        ACCOUNT_NUMBER,
                        EXT_PRD_ID_TX,         
                        EXT_PRD_HLD_ID_TX,
                        EXT_SYS_ID,
                        EXT_PTY_ID_TX,
                        ACCOUNT_TYPE_CD,
                        COM_PFR_TYP_TX,
                        COM_PFR_OPT_TX,
                        COM_PFR_RSN_CD,
                        status)
         VALUES
                        (pc_id,
                         v_rt_all_cols(i).party_id,
                         decode(v_rt_all_cols(i).product_brand,'LTB',2,'HLX',1,'HAL',1,'BOS',3,'VER',4,0),
                         v_rt_all_cols(i).sort_code,
                         'XXXX'||substr(trim(v_rt_all_cols(i).ACCOUNT_NUMBER),length(trim(v_rt_all_cols(i).ACCOUNT_NUMBER))-3,4),
                         v_rt_all_cols(i).EXT_PRD_ID_TX,
                         v_rt_all_cols(i).EXT_PRD_HLD_ID_TX,
                         v_rt_all_cols(i).EXT_SYS_ID,
                         v_rt_all_cols(i).EXT_PTY_ID_TX,
                         v_rt_all_cols(i).ACCOUNT_TYPE_CD,
                         v_rt_all_cols(i).COM_PFR_TYP_TX,
                         v_rt_all_cols(i).COM_PFR_OPT_TX,
                         v_rt_all_cols(i).COM_PFR_RSN_CD,
                         NULL);
              vstep_no  := '4.3';
              vtable_nm := 'after insert corres';
    else
          select COM_SEQ.nextval into id_val from dual;
              vstep_no  := '6';
              vtable_nm := 'before insertcomm';
      if (upper(v_rt_all_cols(i).event_type) = upper('REMINDER')) then
            vstep_no  := '6.01';
              vtable_nm := 'after if insertcomm';
          insert into parent_tab
             (ID ,
             CTEM_CODE,
             CHA_CODE,            
             CT_CODE,                           
             CONTACT_POINT_ID,             
             SOURCE,
             RECEIVED_DATE,                             
             SEND_DATE,
             RETRY_COUNT)
          values
             (id_val,
              lower(v_rt_all_cols(i).event_type), 
              decode(v_rt_all_cols(i).product_brand,'LTB',2,'HLX',1,'HAL',1,'BOS',3,'VER',4,0),
              'Email',
              v_rt_all_cols(i).email_id,
              'IADAREMINDER',
              systimestamp,
              systimestamp,
              0);  
     else
            vstep_no  := '6.02';
              vtable_nm := 'after else insertcomm';
          insert into parent_tab
             (ID ,
             CTEM_CODE,
             CHA_CODE,            
             CT_CODE,                           
             CONTACT_POINT_ID,             
             SOURCE,
             RECEIVED_DATE,                             
             SEND_DATE,
             RETRY_COUNT)
          values
             (id_val,
              lower(v_rt_all_cols(i).event_type), 
              decode(v_rt_all_cols(i).product_brand,'LTB',2,'HLX',1,'HAL',1,'BOS',3,'VER',4,0),
              'Email',
              v_rt_all_cols(i).email_id,
              'CORRESPONDENCE',
              systimestamp,
              systimestamp,
              0); 
        END if; 
              vstep_no  := '6.11';
              vtable_nm := 'before chop';
         if (v_rt_all_cols(i).ACCOUNT_NUMBER is not null) then 
                  v_rt_all_cols(i).ACCOUNT_NUMBER := 'XXXX'||substr(trim(v_rt_all_cols(i).ACCOUNT_NUMBER),length(trim(v_rt_all_cols(i).ACCOUNT_NUMBER))-3,4);
          insert into child_tab
             (COM_ID,                                            
             KEY,                                                                                                                                            
             VALUE)
          values
            (id_val,
             'IB.Correspondence.AccountNumberMasked',
             v_rt_all_cols(i).ACCOUNT_NUMBER);
         end if;
              vstep_no  := '6.1';
              vtable_nm := 'before stateday';
         if (v_rt_all_cols(i).crr_day is not null) then 
          insert into child_tab
             (COM_ID,                                            
             KEY,                                                                                                                                            
             VALUE)
          values
            (id_val,
             --'IB.Correspondence.Date.Day',
             'IB.Crsp.Date.Day',
             v_rt_all_cols(i).crr_day);
         end if;
              vstep_no  := '6.2';
              vtable_nm := 'before statemth';
         if (v_rt_all_cols(i).crr_month is not null) then 
          insert into child_tab
             (COM_ID,                                            
             KEY,                                                                                                                                            
             VALUE)
          values
            (id_val,
             --'IB.Correspondence.Date.Month',
             'IB.Crsp.Date.Month',
             v_rt_all_cols(i).crr_month);
         end if;
              vstep_no  := '6.3';
              vtable_nm := 'before stateyear';
         if (v_rt_all_cols(i).crr_year is not null) then 
          insert into child_tab
             (COM_ID,                                            
             KEY,                                                                                                                                            
             VALUE)
          values
            (id_val,
             --'IB.Correspondence.Date.Year',
             'IB.Crsp.Date.Year',
             v_rt_all_cols(i).crr_year);
         end if;
              vstep_no  := '7';
              vtable_nm := 'before type';
           if (v_rt_all_cols(i).product_type is not null) then
              insert into child_tab
                 (COM_ID,                                            
                 KEY,                                                                                                                                        
                 VALUE)
              values
                (id_val,
                 'IB.Product.ProductName',
               v_rt_all_cols(i).product_type);
            end if;
              vstep_no  := '9';
              vtable_nm := 'before title';         
          if (trim(v_rt_all_cols(i).title) is not null) then
          insert into child_tab
             (COM_ID,                                            
             KEY,                                                                                                                                            
             VALUE )
          values
            (id_val,
             'IB.Customer.Title',
             trim(v_rt_all_cols(i).title));
          end if;
              vstep_no  := '10';
              vtable_nm := 'before surname';
          if (v_rt_all_cols(i).surname is not null) then
            insert into child_tab
               (COM_ID,                                            
               KEY,                                                                                                                                          
               VALUE)
            values
              (id_val,
              'IB.Customer.LastName',
              v_rt_all_cols(i).surname);
          end if;
                        vstep_no  := '12';
                        vtable_nm := 'before postcd';
          if (trim(v_rt_all_cols(i).POSTCODE) is not null) then
          insert into child_tab
             (COM_ID,                                            
             KEY,                                                                                                                                            
             VALUE)                              
           values
            (id_val,
             'IB.Customer.Addr.PostCodeMasked',
              substr(replace(v_rt_all_cols(i).POSTCODE,' ',''),length(replace(v_rt_all_cols(i).POSTCODE,' ',''))-2,3));
          end if;
                        vstep_no  := '13';
                        vtable_nm := 'before subject';
          if (trim(v_rt_all_cols(i).SUBJECT) is not null) then
          insert into child_tab
             (COM_ID,                                            
             KEY,                                                                                                                                            
             VALUE)                              
           values
            (id_val,
             'IB.Correspondence.Subject',
              v_rt_all_cols(i).subject);
          end if;
                        vstep_no  := '14';
                        vtable_nm := 'before inactivity';
          if (trim(v_rt_all_cols(i).UNREAD_CORRES_PERIOD) is null or
              trim(v_rt_all_cols(i).UNREAD_CORRES_PERIOD) = '3' or
              trim(v_rt_all_cols(i).UNREAD_CORRES_PERIOD) = '6' or
              trim(v_rt_all_cols(i).UNREAD_CORRES_PERIOD) = '9') then
          insert into child_tab
             (COM_ID,                                            
             KEY,                                                                                                                                            
             VALUE)                              
           values
            (id_val,
             'IB.Correspondence.Inactivity',
              v_rt_all_cols(i).UNREAD_CORRES_PERIOD);
          end if;
                      vstep_no  := '14.1';
                      vtable_nm := 'after notfound';
    end if;
                      vstep_no  := '15';
                      vtable_nm := 'after notfound';
    END LOOP;
    end loop;
                      vstep_no  := '16';
                      vtable_nm := 'before closecur';
    CLOSE stg_cursor;
                      vstep_no  := '17';
                      vtable_nm := 'before commit';
    DELETE FROM table_stg;
  COMMIT;
                      vstep_no  := '18';
                      vtable_nm := 'after commit';
EXCEPTION
WHEN OTHERS THEN
  ROLLBACK;
  success_flag := 1;
  vsql_code := SQLCODE;
  vsql_errm := SUBSTR(sqlerrm,1,200);
  error_logging_pkg.inserterrorlog('samp',vsql_code,vsql_errm, vtable_nm,vstep_no);
  RAISE_APPLICATION_ERROR (-20011, 'samp '||vstep_no||' SQLERRM:'||SQLERRM);
end;
Thanks

Its bit urgent
NO - it is NOT urgent. Not to us.
If you have an urgent problem you need to hire a consultant.
I have a performance issue in the below code,
Maybe you do and maybe you don't. How are we to really know? You haven't posted ANYTHING indicating that a performance issue exists. Please read the FAQ for how to post a tuning request and the info you need to provide. First and foremost you have to post SOMETHING that actually shows that a performance issue exists. Troubleshooting requires FACTS not just a subjective opinion.
where i am trying to insert the data from table_stg into target_tab and in parent_tab tables and then to child tables via cursor with bulk collect .the target_tab and parent_tab are huge tables and have a row wise trigger enabled on it .the trigger is mandatory . This timetaken for this block to execute is 5000 seconds.Now my requirement is to reduce it to 5 to 10 mins.
Personally I think 5000 seconds (about 1 hr 20 minutes) is very fast for processing 800 trillion rows of data into parent and child tables. Why do you think that is slow?
Your code has several major flaws that need to be corrected before you can even determine what, if anything, needs to be tuned.
This code has the EXIT statement at the beginning of the loop instead of at the end
    FETCH stg_cursor BULK COLLECT INTO v_rt_all_cols LIMIT limit_in;
              vstep_no  := '4';
              vtable_nm := 'after fetch';
--EXIT WHEN v_rt_all_cols.COUNT = 0;
    EXIT WHEN stg_cursor%NOTFOUND;
The correct place for the %NOTFOUND test when using BULK COLLECT is at the END of the loop; that is, the last statement in the loop.
You can use a COUNT test at the start of the loop but ironically you have commented it out and have now done it wrong. Either move the NOTFOUND test to the end of the loop or remove it and uncomment the COUNT test.
WHEN OTHERS THEN
  ROLLBACK;
That basically says you don't even care what problem occurs or whether the problem is for a single record of your 10,000 in the collection. You pretty much just throw away any stack trace and substitute your own message.
Your code also has NO exception handling for any of the individual steps or blocks of code.
The code you posted also begs the question of why you are using NAME=VALUE pairs for child data rows? Why aren't you using a standard relational table for this data?
As others have noted you are using slow-by-slow (row by row processing). Let's assume that PL/SQL, the bulk collect and row-by-row is actually necessary.
Then you should be constructing the parent and child records into collections and then inserting them in BULK using FORALL.
1. Create a collection for the new parent rows
2. Create a collection for the new child rows
3. For each set of LIMIT source row data
  a. empty the parent and child collections
  b. populate those collections with new parent/child data
  c. bulk insert the parent collection into the parent table
  d. bulk insert the child collection into the child table
And unless you really want to either load EVERYTHING or abandon everything you should use bulk exception handling so that the clean data gets processed and only the dirty data gets rejected.

Similar Messages

  • The demand of my application is that i can not replace for loop with a while loop.because i need fixed number of iterations and as far as i know fixed iterations could be only with possible with the for loop.

    the demand of my application is that i can not replace for loop with a while loop.because i need fixed number of iterations and as far as i know fixed iterations could be only with possible with the for loop.
    your recommended second option that i could add true/false case.
    this true/false case must be inside the for loop or outside the for loop?if this case is inside the for
    loop, how can i send stop command from outer while
    loop?
    more over do you have any example for this please?
    thanks"

    You can execute a fixed number of iterations using a while loop by comparing the iteration count to the number of iterations you want and wiring the output of that comparison (e.g. Less Than or Equal To) to the continue (or stop) terminal of your while loop. Which comparison you use depends on personal preference, where you wire the desired count and the interation count, and whether you're using the while loop as Continue if True or Stop if True.
    Ben gave you step-by-step instructions in response to your previous question. Look here for Ben's response.
    Ben's response looks pretty good and detailed to me. It certa
    inly deserved better than a 1-star rating.

  • I'm trying to transfer my pictures from my iPhoto library to my external hard drive. I dragged the iPhoto Library folder into the drive and after waiting a while it says Error Code -36. I need to free up space asap, what should i do?

    I'm trying to transfer my pictures from my iPhoto library to my external hard drive. I dragged the iPhoto Library folder into the drive and after waiting a while it says "Error Code -36 The finder cannot complete the operation because some data in 'iPhoto Library' could not be read or written". I need to free up space asap, what should i do??

    Yes, the Old Master file has a folder for each year where I find all photos from that specific year. I am attaching a screen shot of the file.
    In the meantime i have managed to download all photos (it did not download any video files though in mpg, avi, 3gp, m4v,mp4 and mov format) to a new iphoto library. Unfortunately the photos are quite mixed and often doubled up. I ma considering to purchase iphoto library which checks all duplicates in iphoto. this will save me a lot of time. What do you think?

  • Need help with the for loop

    Hello,
    I hope someone can point me in the right direction for my next assignment. I am very new at Java programming. For my next assignment for class I will need expand my previous program which was a mortgage calculator. The first assignment we wrote a program to show the monthly payments of a $200,000 loan at 5.75% for 30 years. Now we have to output all 360 monthly payments with pauses in between so it doesnt scoll off the page. The calculation that we use is:
    month_payments = (principle * monthlyinterest) / (1-Math.pow(1 + monthlyinterest, - months));
    My question is how do I get the correct calculation outputed 360 times. I would like to use the "for loop" to do this. Also what is the correct way to do the pause command? I do not want someone to write the code, I just want some help to where I need to start off, I want to learn this on my own.
    Thanks in advance,
    DC

    for (int i ; i < 10 ; i ++ ) { System.out.println("Come sail away"); }
    or;
    int i = 0;
    while(i < 10)
        i++;
        System.out.println("Come sail away");
    }

  • I want to turn my macbook air off. the shut down button already appeared but the mouse/cursor just hang and won't work. even after pressing the enter button to shut my mac off won't work. what will i do?

    i want to turn my macbook air off. the shut down button already appeared but the mouse/cursor just hang and won't work. even after pressing the enter button to shut my mac off won't work. what will i do?

    This is not a reply. I just want to elaborate on this problem.
    My computer freezes occasionally when it is used after being sleep for a while. The spinning ball appears and everything is totally disabled. Nothing on the keyboard works.
    The mouse moves, but does not work.
    The only solution is to turn the power off and on (losing all data in open applications.)
    I kept the System monitor running on the side to find out which program was running when the computer froze. The Monitor as well as all other applications froze, but the data showed:
    Firefox 18.4%
    Activity Monitor 0.9%
    Firefox Plugin 0.2%
    This is all the information I have. By the way, I am using iMac with OS 10.6.

  • In Dreamweaver, I need to add the directory to the File being inserted in the following Insert Code:    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 202, 1, 255, Request.Form("DocLocation")) ' adVarWChar

    I have the following code:
    <%
    If (CStr(Request("MM_insert")) = "form1") Then
      If (Not MM_abortEdit) Then
        ' execute the insert
        Dim MM_editCmd
        Set MM_editCmd = Server.CreateObject ("ADODB.Command")
        MM_editCmd.ActiveConnection = MM_NewFLSSARDB_STRING
        MM_editCmd.CommandText = "INSERT INTO DocumentTable (Title, DocLink, UpdatedBy, UpdateDate, Type, Comments) VALUES (?, ?, ?, ?, ?, ?)"
        MM_editCmd.Prepared = true
        MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 202, 1, 255, Request.Form("DocumentName")) ' adVarWChar
        MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 202, 1, 255, Request.Form("DocLocation")) ' adVarWChar
        MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param3", 202, 1, 255, Request.Form("UpdatedBy")) ' adVarWChar
        MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param4", 135, 1, -1, MM_IIF(Request.Form("UpdatedDate"), Request.Form("UpdatedDate"), null)) ' adDBTimeStamp
        MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param5", 202, 1, 255, Request.Form("Type")) ' adVarWChar
        MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param6", 203, 1, 1073741823, Request.Form("Comments")) ' adLongVarWChar
        MM_editCmd.Execute
        MM_editCmd.ActiveConnection.Close
        ' append the query string to the redirect URL
        Dim MM_editRedirectUrl
        MM_editRedirectUrl = "testFLSSARSuperAdminIndex.asp"
        If (Request.QueryString <> "") Then
          If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0) Then
            MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
          Else
            MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
          End If
        End If
        Response.Redirect(MM_editRedirectUrl)
      End If
    End If
    %>
    For param2 above I need to add the directory "Docs/" to the command so that the file can be found by the User.  How do I do that?

    If all documents are going to the "/Docs" folder, then I wouldn't include it in the inserted data as you can just add it dynamically where needed. If you do want to include it and it's not part of the posted form data, then just concatenate it (&) prior to inserting into the table.

  • I am trying to reinstall Master Collection after a computer crash and after download it will not accept the serial number that it lists on my purchased products.  The purchase was in 2012.

    I am trying to reinstall Master Collection after a computer crash and after download it will not accept the serial number that it lists on my purchased products.  The purchase was in 2012.The message says the serial number is invalid.  What do I do nest?

    Hi there,
    Please see help here - https://helpx.adobe.com/creative-suite/kb/error-serial-number-valid-product.html
    If still you are facing problem, I would recommend to reach out to support through the link which is available at the bottom of the support page.
    ^Ani

  • When I try to simply add a few photos (from Events) into a newly created Album, it always creates a Folder for the photos to go into. I don't need a Folder.  I just need the photos to go into the Album.  What am I doing wrong?

    When I try to simply add a few photos (from Events) into a newly created Album, it always creates a new Folder - a sub folder to the new Album I just created -  for the photos to go into. I don't need a Folder!  I just need the photos to add into the Album.  What am I doing wrong?

    Sometimes it takes a precise drop to get it into the album.  Make sure you see the album highlighted before releasing the mouse:
    OT

  • I need to organize medical photos.  They are pre-op and post-op photos.  What is the best way to organize them.  should I use iphoto or is that too much trouble.

    I need to organize medical photos.  They are pre-op and post-op photos.  What is the best way to organize them?  should I use iphoto or is that too much trouble? Since they occur on different days, organizing by event does not seem appropriate.  Also, organizing by face is not always possible as some are close up photos of an individual eye.  Surely, this has been done before, and I don't want to spin my wheels reinventing this.

    Who can tell with that amount of information to work with?
    iPhoto is not limited to Events or Faces as organizational tools - Albums, Keywords, various forms of metadata can be leveraged for use as well, and these are often more flexible. Really it's up to you to look at the tools available and see if they suit your usage scenario.

  • My husband gave me his iPod touch, even after resetting all settings, and even though I have a user name and password whenever I need to update apps it shows his previous user name,  and is asking for his password.  How do I fix that?

    My husband gave me his iPod touch, even after resetting all settings, and even though I have a user name and password, whenever I need to update apps it shows his previous user name,  and is asking for his password.  How do I fix that?

    dom59 wrote:
    Ok, when I go into my Apple ID account, everything looks right.  It does show my user name.  It's only on the iPod that it shows my husband's previous user name, and it asks for his password.  Everything in iTunes and my account looks right.  The issue only seems to be with the actual device, iPod Touch 4th gen.
    There is more than one way to access the Apps Store and the iTunes store.  One is via iTunes on your computer, and the other is via the apps on your iPod.
    Just because you are logged in on your computer does not mean you are logged in on your iPod.
    The reason your husband's user name comes up is because he was the last one to log on.  You can change that by going to Settings>Store.  Tap the Apple ID, Tap Sign Out, Tap Sign In, Tap Use Existing Appel ID, enter your e-mail address and Apple ID password, and tap OK.

  • This maybe a dumb question but...If I buy Aperture are the updates already installed into the purchased version or do I need to update them?

    This maybe a dumb question but...If I buy Aperture are the updates already installed into the purchased version or do I need to update them after the prograam is installed?

    Should come updated from the Mac App Store. Obviously, it's tough to keep things up to date when they are sitting in a box on a store shelf.

  • I need help changing my security information because i forgot it and i clicked forgot your answers on the apple website and its sopost to send me an email saying how to reset it but i never got an email

    i need help changing my security information because i forgot it and i clicked forgot your answers on the apple website and its sopost to send me an email saying how to reset it but i never got an email.

    Contact iTunes support:
    http://www.apple.com/support/itunes/contact/

  • Bulk Collects in Cursors

    Im enhancing a piece of code I have written and would like to use a bulk collect to enter values into my collection, rather than multiple switches.
    Can someone advise me on the correct use of bulk collects with cursors? Is it possible, or should I simply enter the SQL directly into the PLSQL?
    Thanks

    It's not only possible but preferrable to use BULK COLLECT to fetch cursor data into collections. If you search the Oracle documentation at http://tahiti.oracle.com for BULK COLLECT, you'll get plenty of hits that walk you through the details. Basically, though, you want something like this (lifted from the PL/SQL User's Guide)
    DECLARE
       TYPE NumTab IS TABLE OF emp.empno%TYPE;
       TYPE NameTab IS TABLE OF emp.ename%TYPE;
       enums NumTab;  -- no need to initialize
       names NameTab;
    BEGIN
       SELECT empno, ename  
         BULK COLLECT INTO enums, names
         FROM emp;
    END;Justin
    Distributed Database Consulting, Inc.
    www.ddbcinc.com/askDDBC

  • I need an help regarding Bulk collect

    Can we use bulkcollect with sys_refursor ?
    for ex :
    create or replace procedure sampelpro ( recs out sys_refcursor) is
    begin
    execute immediate 'select * from table1' bulk collect into recs ;
    end sampelpro;
    Note : table1 has 1+ laks record
    if the above code is not possible then let me know any possible ways ?

    Hi and welcome to the forum
    Can we use bulkcollect with sys_refursor ?No, and you shouldn't.
    Your signature says that OUT parameter is a cursor. A cursor is not a resultset, but rather a pointer to one.
    So your best choice is probably just to use that, and not try to select into a collection.
    Note : table1 has 1+ laks recordEven more important then not to return a collection, but a cursor. (Although I don't remember what a lak is)
    Example on how to use:
    create or replace procedure sampelpro (recs out sys_refcursor)
    is
    begin
        open recs for 'select empno, ename from emp';
    end sampelpro;
    Procedure er oprettetAnd a test. Imagine this being a Java client or something the like
    SQL> var c refcursor
    SQL> exec sampelpro(:c)
    PL/SQL-procedure er udf°rt.
    SQL> print c
         EMPNO ENAME
          7369 SMITH
          7499 ALLEN
          7521 WARD
          7566 JONES
          7654 MARTIN
          7698 BLAKE
          7782 CLARK
          7788 SCOTT
          7839 KING
          7844 TURNER
          7876 ADAMS
         EMPNO ENAME
          7900 JAMES
          7902 FORD
          7934 MILLER
    14 rµkker er valgt.
    SQL>Blushadow has a nice post on cursors here:
    PL/SQL 101 : Understanding Ref Cursors
    Regards
    Peter

  • Moving xy graph cursor with mouse and programmab​ly controllin​g snap to point

    Hi,
    I have run into a bit of a problem. I am trying to create a program which allows a user to select a location on an XY graph by simply clicking in the vacinity of the plot. Most of it is working, however I find that I can't programmably control the snap to point function reliably.
    I hope this is a clear outline of the problem:
    - The cursor starts in a Free state, so that when the
    user clicks in the plot area, I can set the cursor
    position to the nearest point by setting the
    CursorPosition using the graph's property node.
    - Maybe the user didn't like the chosen location and
    wants to drag the cursor over a bit. Ok, user drags
    the cursor to a new position.
    - Now th
    e cursor position is probably not exactly on
    the plot trace. If, at this point, I set the cursor
    to Snap To Point, the cursor does not snap to the
    nearest point on the graph (relative to its current
    position), but instead to the last place a _mouse_
    action placed it.
    - Immediately after the new location has been set,
    the cursor state has to be reset to free in case I
    need to programmably move the cursor again (I
    can't seem to programmably control the mouse in
    any state but Free)
    How do I go about getting the cursor to snap to the closest point at it's new location? I'm at a loss.
    Any insight you might have would be greatly appreciated.
    Thanks much!
    Tere

    So what is the question about... I have to use XY graph in my program. It is used in Loop while cycle. It shows the statistic of a variable. I am using cursors in this graph to check the actual value of a variable in different period of time. But there are 7 variables and it is extremely hard for user to check each value independently. So I tried to make them moving on the X axis (TIME) together using the property node (cursors reading the position (only X axis, Y axis status lock to plot) of the major cursor and follow it... Everything looks great? But it did not work when I am trying to move the major cursor manually on graph... It works only when I am using the cursor movement buttons... But they work very slowly when there is a lot of data in graph.
    I want to find out is it possible to make seven coursers mouthing together By the X axe and be Locked each at its plot by Y axe manually (Using mouse moving on a graph). Is it possible? If it is than how to do it?

Maybe you are looking for