Help Required with PL/SQL loading logic

Hi All,
We have a simple pl/sql code which does loading(insertions) of records into the table. This pl/sql code actually refers to an translation website URL(microsoft based) and inserts the translated text into our table. What happens is sometimes this URL gets blocked out due to some issue. So we are forced to restart our entire operation of loading once again. Actually we have a commit at the end(outside the loop). on the other hand we cant keep commit inside the loop as it may pose an overhead to performance since its commiting once every insert happens.
What we are expecting is something like this. Say we have 10,000 records. the loading fails at 5500 record. next time when we start again we want to start from 5501 record and NOT from beginning. In informatica kind of ETL tools we have an option to do this. However not sure if we can do this through PL/SQL.
we thought of keeping counter variable and keep it incrementing for each and every insert happens. but before doing this we have to order by our table according to primary key. This is taking huge amount of time since the table is very big.
can you please tell any alternative to this?
Regards,
Paul

If I understand correctly, you are doing something as follows:
// process a defined data set
for c in (select .. some data... ) 
loop
    // translate the data (via a web service call)
    Translate( c, translatedOutput )
    // insert the translated data
    insert into some_table translatedOutput
end loop
commitIn principle, nothing wrong with this approach. And yes, committing inside the loop for every x number of rows will increase the complexity of code and could perhaps violate ANSI SQL standards of fetching across commits.
A better approach would be to consider parallelising this process. Run multiple copies of that code - but provide each copy of the code with a small and unique data set to process. So instead of doing 10,000 rows in serial, you schedule a 100 jobs and give each a unique set of a 100 rows to translate.
Let's say your job queue size is set to 20. This means up to 20 of these processes will run in parallel. Should one fail, the job manager will automatically reschedule it for execution (up to 16 times after which it will be marked as broken).
So not only does this type of approach enables you spread the processing load, it also enables you to scale your processing (you can handle much larger data volumes like this, and more powerful server h/w will enable you to use more parallel processes). In addition, restart is automated courtesy of the Oracle job manager.
Compare this type approach with committing inside a loop.. The latter buys you what ito flexibility and performance and scalability? Nothing really - it only makes the process a lot more complex as it needs to be able to correctly restart after a failure. You will not be able to process bigger volumes of data. You will not be able to increase existing performance.
One needs to carefully consider the approach used to processing data - serialisation is inherently limited. Restarting serialised processes is difficult and complex.

Similar Messages

  • Help required to build SQL loader control file

    I have a table, That we need to load using SQL loader.
    table structure is --
    <emp_id>,<first_name>,<middle_name>,<last_name>,<sal>
    The structure of flat file is like below,
    <emp_id>|<emp_name>|<sal>
    <emp_name> field can contain space to define first name, middle name and last name,
    if no space is there means we only need to load first name. and one space means First and last name should load.
    Sample flat file--
    1001|Ram|10000
    1002|Syam Kumar Sharma|20000
    1003|Jadu Prashad|15000
    Please help me out to build the control file.
    Thanks in Advance

    Means, can use DBMS_SCHEDULER for loading data ?Yes, you can create procedures for that and let the scheduler execute them on the desired interval
    (you can even execute OS commands through DBMS_SCHEDULER).
    Read about it here:
    http://www.oracle.com/pls/db102/search?word=DBMS_SCHEDULER&partno=
    http://www.oracle-base.com/articles/10g/Scheduler10g.php
    By the way, instead of using sqlloader why not switch to using external tables?
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:6611962171229
    http://www.oracle-base.com/articles/9i/SQLNewFeatures9i.php#ExternalTables
    A few other approaches (pre 10g)
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:2048340300346698595
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:3084681089099

  • Help required with Photoshop Elements 4.0 this has been installed on my new Toshiba laptop with windows 8.1 for some 18 months and operating well. Now it will not open, message pops up saying "attempt to access invalid address" then "application not respo

    Help required with Photoshop Elements 4.0 this has been installed on my new Toshiba laptop with windows 8.1 for some 18 months and operating well. Now it will not open, message pops up saying “attempt to access invalid address” then “application not responding” Suggestions how to access would be much appreciated. Tks. Stuart

    What is the size of your hard disk?  PSE 4 is a very old program and I suspect it is not able to access the entire hard disk on your machine.  Just a thought here.

  • Help require with installing Adobe Acrobat onto my Macbook Pro Retina.

    Help require with installing Adobe Acrobat onto my Macbook Pro Retina.
    I have successfully installed all of my creative cloud apps with the exception being acrobat.
    I cannot print from Indesign to PDF.
    I have unistalled, reinstalled and still no Adobe Acrobat.
    I now have to go back to Windows 8 and create the PDF's there.
    Any one know how to get around this issue?
    Thanks in advance
    Kelvin

    OSX has effectively killed the ability to print to pdf, (print to pdf eliminates most of the "Rich features" of current pdf).
    Export from InDesign, always, excpet for the 1% of the time where you know why print to pdf would produce a better result.

  • Help required with (soundcard) connection / settings, thanks in advan

    Help required with connection / settings between a Creative Sound Blaster Audigy Platinum EX (soundcard) and a Creative DTT3500 Digital (5. speakers).
    The problem
    No sound from any of the speakers. (Exception can plug in headphones at front)
    Background
    My computer has been recently upgraded at my local computer shop and all programs re-installed (including driver update from Creative's website). However after reconnecting speakers and restoring the original settings I?m getting no sound from any of the speakers. I?ve followed all the available advice/instructions I can find on this website and manuals to no avail.
    Set-up
    Physical
    (Digital DIN) Speakers/decoder amplifier (DTT3500) connected to the (digital out) soundcard (Audigy Platinum EX) using minijack to DIN cable. (As per instruction manual)
    Software
    Creative Audio Consul ? setting as per instructions, however have tried variations in vain. (Note: above tabs there is a select device box with SB Audigy [A0000] in it ? only option. Just wondering what [A0000] means?)
    Your advice please. A simple step by step guide would be appreciated, many thanks in advance, Jon

    "My computer has been recently upgraded at my local computer shop and all programs re-installed (including driver update from Creative's website). "
    Do you have the original installation disk?
    If so, try installing THOSE drivers, ESPECIALLY if it worked before. Be sure to uninstall what is there now, first.
    Its natural for most people to want the 'latest' drivers for their hardware. However:
    After experiencing some difficulties with some CL 'updates' for certain products, I now avoid them UNLESS I am having a PROBLEM with the existing drivers.

  • Help required with User exit logic

    Hi gurus,
    Please help me with the logic I wrote for the user exit for a PP Work Center View extract structure. Here is the details of the add on fields: VGW01, VGW02, VGW03, STEUS(from table PLPO); DataSource: 2LIS_04_P_ARBPL,
    data: l_s_pp1 like MC04P_0ARB(extract structure of 2LIS_04_P_ARBPL),
    l_tabix like sy-tabix,
    lv_VGW01 like PLPO-VGW01.
    lv_VGW02 like PLPO-VGW02.
    lv_VGW03 like PLPO-VGW03.
    lv_STEUS like PLPO-STEUS.
    tables : PLPO.
    case i_datasource.
    when '2LIS_04_P_ARBPL'.
    loop at c_t_data into l_s_pp1.
    select single vgw01into lv_vgw01
    from PLPO
    where field = l_s_pp1-field.
    if sy-subrc = 0.
    l_s_pp-zzvgw01 = lv_vgw01.
    l_s_pp-zzvgw02 = lv_vgw02.
    l_s_pp-zzvgw03 = lv_vgw03.
    l_s_pp-zzsteus  = lv_steus.
    endif.
    modify c_t_data from l_s_pp1 index l_tabix.
    endloop.
    Any additional comments welcome. Thanks in advance.

    Hi,
    Try coding as per the below code
    case i_datasource.
      When '2LIS_04_P_ARBPL'.
      DATA: lt_data TYPE TABLE OF MC04P_0ARB.
      FIELD-SYMBOLS: <ls_data> TYPE MC04P_0ARB.
    Internal table for
      TYPES:
            BEGIN OF ty_tbl1,
                     lv_VGW01 TYPE PLPO-VGW01,
                     lv_VGW02 TYPE PLPO-VGW02,
                     lv_VGW03 TYPE PLPO-VGW03,
                     l_bmsch  TYPE XXXX-XXXX,
                     l_plnnr  TYPE XXXX-XXXX
                     l_datuv  TYPE XXXX-XXXX
                     l_aennr  TYPE XXXX-XXXX
                     l_plnkn  TYPE XXXX-XXXX
                     l_plnal  TYPE XXXX-XXXX
            END OF ty_tbl1.
      DATA:
             lt_tb1 type standard table of ty_tbq,
             ls_tb1 type ty_tb1.
      lt_data[] = c_t_data[].
    Read data into internal memory using jOins
      select aVGW01 aVGW02 aVGW02 aVGW02 bbmsch bplnnr bdatuv baennr bplnkn bplnal into into  CORRESPONDING FIELDS OF TABLE
      lt_tb1 from PLPO as a innerjoin XXXX as b where aXXXX=bXXXX.        
    use the internal table to get the data to the enhaced fileds
    LOOP AT lt_data ASSIGNING <ls_data>.
        read table lt_tb1 into ls_tb1
             with key XXXXX = <ls_data>-XXXX .
        if sy-subrc eq 0.
          <ls_data>-lV_VGW01 = ls_tb1-lv_VGW01,
          <ls_data>-lV_VGW02 = ls_tb1-lv_VGW02,
          <ls_data>-lV_VGW03 = ls_tb1-lv_VGW03,
          <ls_data>-bmsch    = ls_tb1-bmsch,
          <ls_data>-plnnr    = ls_tb1-plnnr,
          <ls_data>-datuv    = ls_tb1-datuv,
          <ls_data>-aennr    = ls_tb1-aennr,
          <ls_data>-plnkn    = ls_tb1-plnkn,
          <ls_data>-pln1l    = ls_tb1-plnal.
          MODIFY lt_data FROM <ls_data>.
        endif.
      ENDLOOP.
      REFRESH c_t_data.
      c_t_data[] = lt_data[].
    Note that the code is not written with the exact fields. Change the fields where necessary(also i have joined only 2 tables if needs to be joind form more than 2  table change the join statement accordingly).
    Thanks,
    Nagarjuna
    Edited by: Nagarjuna Reddy on Oct 20, 2011 3:39 AM

  • Please help me with this SQL query

    I am practicing SQL queries and have come across one involving fetching data from 3 different tables.
    The three tables are as below
    <pre>
    Country
    location_id          country
    loc1          Spain
    loc2          England
    loc3          Spain
    loc4          USA
    loc5          Italy
    loc6          USA
    loc7          USA
    </pre>
    <pre>
    User
    user_id location_id
    u1 loc1
    u2 loc1
    u3 loc2
    u4 loc2
    u5 loc1
    u6 loc3
    </pre>
    <pre>
    Post
    post_id user_id
    p1 u1
    p2 u1
    p3 u2
    p4 u3
    p5 u1
    p6 u2
    </pre>
    I am trying to write an SQL query - for each country of users, display the average number of posts
    I understand the logic behind this that we first need to group together all the locations and then the users belonging to one country and then find the average of their posts.
    But, i'm having a difficulty in putting this in SQL form. Could someone please help me with this query.
    Thanks.

    select
    country.country,
    count(*) Totalpostspercountry,
    count(distinct post.user_id) Totaldistincuserspercountry,
    count(*)/count(distinct post.user_id) Avgpostsperuserbycountry
    from
    country, muser, post
    where country.location_id = muser.location_id
    and muser.user_id = post.user_id
    group by country.country
    The output is like this for your sample data - hope this is what you were looking for :)
    COUNTRY,TOTALPOSTSPERCOUNTRY,TOTALDISTINCUSERSPERCOUNTRY,AVGPOSTSPERUSERBYCOUNTRY
    England,1,1,1,
    Spain,5,2,2.5,

  • Help required with Select statment..... ASAP pls

    HI All,
    Let me desc my table first .
    01                             NOT NULL VARCHAR2(5)                                                                                                                                                                                  
    02                             NOT NULL VARCHAR2(5)                                                                                                                                                                                  
    03                             NOT NULL VARCHAR2(5)                                                                                                                                                                                  
    04                             NOT NULL VARCHAR2(5)
    31                                                    This is how table has been created(Note:not by me)
    select name from  od_shift  where year=2011 and month='Feb' and  "02"='W"{code}-->no doubt this is working fine
    My problem is ...here rather putting the number directly ("01","02","03"....."31") 
    I need to take it from the first two digits of date('01-feb-2011') 
    like {code}
      select name from  od_shift  where year=2011 and month='Feb' and  to_char(to_date('01-feb-2011','dd-mon-yyyy'),'dd')='W" but this is not working
    kindly help me with this .
    Edited by: Basva on Mar 8, 2011 4:53 AM

    Pleiadian wrote:
    You could do a case statement. It's not elegant, but it works
    Edit: smon's solution is better if pl/sql is an optionI disagree, it's quite elegant given the cirumstances of that sick table. And it definitely beats a dynamic SQL solution.
    @Basva - when will you realize that your table is no good, and needs to be normalized into a more traditional relational table?
    Regards
    Peter

  • SQL LOADER "LOGICAL COMMIT"

    Hello ,
    After each successful execution of sql loader ,it implicitly commits the underlying transactions .
    Why this implicit commit is happening and Can disable this auto commit feature of sql loader ?
    Thanks

    Hi ,
    We cannot stop the commit option in sqlloqder.
    By using the ROWS parameter we can control the feature
    For eg rows=200
    The records will be committed after every 200 records are over only.
    Thanks
    USR0072

  • Immediate help required with this job scheduling scenario

    I have a job that needs to run a procedure hourly but not between 6:00 AM to 8:00 AM and 6:00 PM to 8:00 PM.
    Can anyone help me with how to schedule this job.

    If you use a window the job would only execute if the window opens. If for some reason the window did not open then the job would not execute.
    Windows should be used to specify which resource plan should be active for the time interval.
    In this case you are better off using FREQ=DAILY; BYHOUR=; and specify the hours.

  • Help required with an image

    Hi all,
    I wonder if someone can help me with the following issue.
    If you see the attached image in the top left hand corner their is a square box which is a different shade to the rest of the header.
    I need to rectify this and blend it in with the rest on the header colour; however, I do not know how to do this and would appreciate some assistance in doing this.
    I'm a noobie to photoshop so any help is much appreciated.

    It seems you've copied another portion of the texture to overlay something you didn't want seen...
    As opposed to copy/paste of a rectangular region, this is almost a textbook use for Content Aware Fill, which should (assuming it works properly) match the pattern and blend the colors.
    Try selecting just the blemish or whatever you're trying to cover, then expand the selection a few pixels, then Edit - Fill - Content Aware.
    -Noel

  • Some help required with logic for a dynamic sql query

    i have below code but not sure how to resolve this problem - what i need is to be able to dynamically
    the problem:
    i have a rabbge of paratmeters coming in from a form and need to be able to create a dynamic query string to go into a prepared statement object.
    the problem i have is there are 2 fields year range and year.
    if year range is none i need to create the query string as such :
    where the value of year can be serached on exactly
    str.append("VOLUME_YEAR = ? ");the probelm is if the year range is 5 or year range is 10 i dont know how to maipulate the query string to be able to set the string such that i can then place the year value in the place holder in preparedStatement.setInt(1, year)
    how can i create the intial query string ie.- what are the possible things that i can do. - i'm thinking of things like putting some type of between or such type query statement - but not at all sure how the syntax would go - ie. how would i use the year value and how would i create this dynamic part of the query string so that the JDBC regonises it?
    thanks for any help.
    public String setVolumeYearQuerySt(String year, String yearRange, StringBuffer str){
              String volumeYearQueryString = null;
              Sring doAction= null;
              if (yearRange.equals("None")){str.append("VOLUME_YEAR = ? ");}
              else if(yearRange.equals("5 Years")){doAction = "Nothing";}
              else if (yearRange.equals("10 Years")){doAction = "Nothing";}
              return volumeYearQueryString;
              }

    Saish - thanks a lot for the code example.
    Although, i think its far too advanced for me to understand and try to manipulate it and fit my problem. I'm pretty new to programming as you can probably see from my simple if else type statements. But i'm going to give it a try and see how it goes.
    could you please be kind enough to demonstrate how i could use the above syntax to do the following. --
    i have a year being entered in form .  in the database there is a column year volume which contains year in single year value format and also in a year range  value format - thus as in below - how could i do this -
    eg.
    user can enter a value in the year field a single value or a range value - then he can select +/-5 or 10 yrs range on that value - the DB holds the values as single values and ranges as below -
    one suggested apporach is as follows if a single user is alloweed to enter only a single value in the filed and select a query range +/- 5 etc..
    volume year of �1926-1928� and the user enters �1927�, the query has to find all records where
    look for records that are �less than or equal to� 1927.  It then has to check to see if it contains a range.  For those that it finds containing a range, it has to work out what the �upper� year is and check to see if that is �greater than or equal� to 1927.  If it is, then that is a possible matchanother approach that is suggested is to have a drop down with all years from databse and user is only llowed to select value from drop down and following logic is suggested :
    Because volumes can be received as ranges (e.g. 1964-1966), some extra coding is required where the user asks for a Year Range (such as + or � 5).
    Using the Year selected from the dropdown list, split it into 2 values, a low year and a high year. For example, if �1965-1968� is selected from the year dropdown, split it into �1965� and �1968� for the low year and high year respectively. If �1964� is selected from the year dropdown, split it into �1964� and �1964�. Now take the Year Range that the user has entered into account. For example, if the user has entered 5, subtract 5 from the low year and add 5 to the high year. Using these values, include the following search criteria in the query to the database:-
    (<low year>     BETWEEN
                 left (VOLUME_YEAR, charindex ('-',VOLUME_YEAR + '-') - 1)
         AND     right (VOLUME_YEAR, charindex ('-',VOLUME_YEAR + '-') - 1))
    OR     (<high year>     BETWEEN
                 left (VOLUME_YEAR, charindex ('-',VOLUME_YEAR + '-') - 1)
         AND     right (VOLUME_YEAR, charindex ('-',VOLUME_YEAR + '-') - 1))regards - i think if i could solve the first approach that would be something good as its most user freindly
    thanks

  • Help Required With SQL Subquery Across DB Link - Takes Long Time

    Hi,
    Apologies if this is not the correct forum but I am implementing this through HTMLDB.
    I am trying to run a SQL query over a DB link with a sub query on tables in my HTMLDB workspace.
    The SQL query over the database link takes 1.23 seconds to run on it's own:
    SELECT D.EMAIL_ADDRESS,
    D.COL2,
    D.COL3,
    D.COL4,
    D.COL5,
    D.COL6,
    T.COL1
    FROM SCHEMA.TABLE1@DATABASELINK D,
    SCHEMA.TABLE2@DATABASELINK T
    WHERE D.TABLE_JOIN = T.TABLE_JOIN
    AND T.COL1 = '1111111'
    AND UPPER(D.COL2) IN ('XXXXXX','YYYYYY')
    The SQL query based on HTMLDB workspace tables takes 0.01 seconds to run on it's own:
    SELECT UPPER(A.EMAIL_ADDRESS)
    FROM HTMLDBTABLE1 M, HTMLDBTABLE2 A
    WHERE M.TABLE_JOIN = A.TABLE_JOIN
    AND M.ID = 222
    However when I try and run these together the results take 280 seconds to complete:
    SELECT D.EMAIL_ADDRESS,
    D.COL2,
    D.COL3,
    D.COL4,
    D.COL5,
    D.COL6,
    T.COL1
    FROM SCHEMA.TABLE1@DATABASELINK D,
    SCHEMA.TABLE2@DATABASELINK T
    WHERE D.TABLE_JOIN = T.TABLE_JOIN
    AND T.COL1 = '1111111'
    AND UPPER(D.COL2) IN ('XXXXXX','YYYYYY')
    AND NOT EXISTS
    (SELECT UPPER(A.EMAIL_ADDRESS)
    FROM HTMLDBTABLE1 M, HTMLDBTABLE2 A
    WHERE M.TABLE_JOIN = A.TABLE_JOIN
    AND UPPER(A.EMAIL_ADDRESS) = UPPER(D.EMAIL_ADDRESS)
    AND M.ID = 222)
    Does anyone have any idea why this query is taking so long?
    Please let me know if you require additional information.
    Many thanks,
    Richard.

    I've updated my profile to show my email address, so go ahead and email me the strace output (compressed please). Maximum attachment size for emails to Oracle is 10MB (encoded), so split the strace output in 5MB chunks if necessary.
    poll() is not normally used by the Oracle network layer for client-server connections. So this may be related to an OS network service, such as DNS or NIS. The strace should make this clear (to me anyway).
    Edited by: herb on Aug 14, 2009 10:25 AM

  • Help required with logic

    Moderator message: pleause use a meaningful subject in future
    Hi,
    I have a custom table which has customer ID field and amount field.
    In the report I need to bucket data by amount and no. of customers in that bucket.
    For ex: for amount range 1.00 u2013 25.00 there are 100 customers and total amount $1000.00, 25.01 to 50.00 there are 34 customers  and total amount $20,000 and so on.
    What I am planning to do is fetch records from table into internal table using group by clause,
    SELECT CUSTOMER AMOUNT FROM CUSTOMER_FINES INTO TABLE LT_FINES GROUP BY CUSTOMER AMOUNT.
    This would bring me in the internal table all customers and their fine. Now what would be the best logic to separate them out into groups.
    Approach what I thought of is having two variables for each bucket no_of_customers and total_amount. Then loop through the internal table add If conditions on amount and then accordingly increment no_of_customers for that bucket and add amount to total_amount.
    But the internal table is likely to have a lot of records about half a million. Is this a good approach. Can you'll recommend what is the right way to achieve this.
    Thanks in advance,
    CD
    Edited by: Matt on Dec 17, 2009 10:02 AM

    Hi,
    do this.
    1. create counters for the no of ranges you have say 1.00 u2013 25.00 counter1 total_amt1, 25.01 to 50.00 counter2 total_amt2 etc
    2. loop at your internal table
    3. check which range the amount falls into using IF statement
    4. increment counter* by 1 and add amount to total_amt*
    You are done.
    Regards
    Prasenjit

  • Can someone please help me with this. Loading problems and error codes.

    I have several problems with itunes on my PC. I use 2 PC's and Iphone for work and I have an IPod nano. For about a week I have been having several problems with Itunes. The first problem is I cannot access the store, I get the loading screen and that is it. This screen lasts forever, nothing ever happens it just loads, and loads, and loads. . . .
    I try to sign in thinking that will help the loading issue and I get error message saying "We could not complete your itunes store request. An unknown error occurred (-50)." This happens on both computers. I also cannot download from my iphone, I get the same error message. Running diagnostics does nothing, itunes says everything is in working order. Uninstalling and reinstalling also does nothing. I have had itunes for years now and up until about 10 days ago had no problems. My itunes is not behind a firewall on either computer. I'm saying all of this because I would prefer not to get obvious answers or links that do not help me. Please someone has to know how to fix this.

    Welcome to discussions! This is the rather infamous chkdsk error which will require that you restore your iPod. The following link will give you a complete explanation/instructions.
    http://docs.info.apple.com/article.html?artnum=300554

Maybe you are looking for

  • Web Dynpro file save dialog - for portal

    Hi everyone, I am currently building a Web Dynpro application in which I need to display a File Save Dialog popup on the Netweaver Portal. Now, I used the standard file_save_dialog method from the class CL_GUI_FRONTEND_SERVICES, but this gives me a d

  • Levels no longer work in Photoshop CS5.1

    Levels don't work in my installation of CS 5.1. The dialog comes up but adjustment don't change the image. I reinstalled CS 5.1 but that didn't fix things. Any ideas on what I can do? thanks

  • House bank account & suspense account

    Hi all, Is it possible to make a normal G/L account as a house bank account when some postings are already made in that G/L? Also, how to create a suspense account and link it for payments to the house bank account. Thanks in advance. Stalin.

  • Monitoring activities from the Time Capsule

    I have my TC since the first shipping of Apple and I'm searching for a way to see if there is any activity at all with the HD. I'm concern about a security issue, even if I use WPA2 Personal with time access control and a different psswd for the driv

  • The bottom half of my screen wont work. i cant unlock my phone

    is there anything i can do to fix this