How to handle errors in a loop FOR

Hi all
For the code:
begin
    for vc1 in (select * 
                  from xx_primavera_invoices_detail 
                 where transfered_to_ar = 0 
                   and cust_trx_type_id not in (1000, 1003, 1016, 1023, 1040)
                   and act_end_date is not null) loop
      insert_into_ar_interface(vc1.amount, vc1.uom_code, vc1.quantity, vc1.unit_standard_price, vc1.cust_trx_type_id
                              ,vc1.description, vc1.interface_line_attribute1, vc1.interface_line_attribute2, vc1.interface_line_attribute3, vc1.service_code
                              ,vc1.gl_date, vc1.orig_system_bill_address_id, vc1.orig_system_bill_customer_id, vc1.segment2, vc1.segment3,vc1.customer_name,vc1.payment_type,vc1.currency_code)
      ;
    end loop;
    
    
    update xx_primavera_invoices_detail 
       set transfered_to_ar = 1 
     where transfered_to_ar = 0
       and cust_trx_type_id not in (1000, 1003, 1016, 1023, 1040)
    end;
I want to add a statement of exception if there is no value returned in VC1. I guess that I will never go in the loop statement because no data found in VC1 but the UPDATE will be performed...

Any ideas?

Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - Production
PL/SQL Release 11.1.0.7.0 - Production
"CORE     11.1.0.7.0     Production"
TNS for Linux: Version 11.1.0.7.0 - Production
NLSRTL Version 11.1.0.7.0 - Production
Thanks in advance,
Bahchevanov.

Hello

declare
  v_i_was_in_loop  boolean;
begin
  --
  v_i_was_in_loop ;= false;
  --
  for cur in (select ..)
  loop
    null;
    v_i_was_in_loop := true;
  end loop;
 --
 if v_i_was_in_loop = true
 then
   update...
 end if;
 --
end;

Tags: Database

Similar Questions

  • How to fix error nv4_disp infinite loop for XP...

    Its been occurring for 3 months... This error occurs twice a week and my computer got stuck...

    Hi SaadArshad,

    ·         What is the brand and model of your graphics card?

    ·         Did you do changes on the computer before the show?

    Uninstall and reinstall the drivers for your graphics card and check if this solves the problem.

    Follow these steps to uninstall and reinstall the driver:

    a. right click on my computer, click Propertiesand click the hardware tab, then click Device Manager.

    b. in the list of devices, click on the graphics card.

    c. double-click the device name, and then right-click and select Properties.

    d. tab driver , click Uninstall.

    e. restart the computer.

    f. open the Device Manager select new Display Adapter.

    g. right click and select put to update driver.

    Refer to this article for more information:

    How to manage devices in Windows XP

     http://support.Microsoft.com/kb/283658

     

    You can also download the latest driver for your graphics card and install manually on your computer. Save the driver to the desktop exe file and after you have uninstalled the driver, install the driver manually.

    Let us know if that helps.

  • How will I know if new loops for 10.1.1 has uploaded?

    So I downloaded the new update, but I can't say the old the new loops loops.  Download it and install it or I have to click on the option 'Download the sounds available' in the menu?

    OR

    Can someone give me the name of loop for one of the loops again so I can search my library of loop?  Thank you!

    It is no new loops have been installed for me, but they may have been installed earlier by the logic. Maybe the update adds iOS GarageBand loops, take a look at this list.

    How to get iOS GB loops in GarageBand for Mac.

  • How to fix error: "application not found" for C:\Windows\system32\rundll32.exe _

    I had the virus ' Vista Internet Security 2010 "deleted using McAfee, but now I can't start my programs and browsers because I see the error:"application not found"for C:\Windows\system32\rundll32.exe" ".
    How can I fix this problem? I use Vista SP2

    Your computer is still infected. Only McAfee will take care about that. First run .exe from Doug Knox fix:

    http://www.dougknox.com/XP/file_assoc.htm

    Then follow the instructions here:

    http://www.bleepingcomputer.com/virus-removal/remove-antivirus-Vista-2010 MS - MVP - Elephant Boy computers - don't panic!

  • How to stop and start a loop for

    I got the code and a loop running in a while loop.  What I need to do, is simply to suspend the processing of the loop until a condition is met, but retains its position of iteration throughout each pause time (not necessarily time, just paused until the following condition is met).  I tried wiring of a Boolean value to "continue if true" terminal of the for loop, but the reboot of the iteration count to 0 when the loop is restarted.  Is there a way to stop the loop for and continue to the particular iteration, it is in?

    Breakpoints, conditional, or normal are intended just for debugging your code.  I had the sense of your question as you want make a break is part of the normal operation of your code.  I would NOT recommend using a breakpoint for this situation.  It would make it appear the diagram showing the breakpoint when it occurs.  A user not to mention that the programmer wouldn't know what to do in this case.

    Yes, both the inner and outer loops would shift registers.

    Implementation of a structure dealing with a small loop inside the "case of a break" is feasible.  Depends on what you are or wait while the operation of the program is "paused."

  • How to handle errors in two parallel loops?

    Hello

    I have a loop that contains a structure of event and a second parallel loop that reads digital inputs.

    My question is:

    (a) how can I manage the errors of the various events? So, if in event1 is a mistake that event2 presented as input and can react to this topic. Currently, all events begin with "no error".

    (b) what can I do with the second loop? It is also always startin "without error" and doesn't know anything if there is a mistake in loop1.

    Is this only possible with a global variable?

    Thx for the help

    Create a user-defined event gets triggered whenever an error occurs. The input data to the event must be a cluster of error within another cluster - you'll see why when you go to use it.

    Now create a Subvi when it is called with its cluster of input error indicating an error, it raises the event you created above, otherwise, it does nothing. Install the Subvi in two loops after everything else.

    Register for the user on the structure of your event event and put what you want to happen when an error occurs in its event handler. Probibly should give you the option of quiting. If an error occurs in each loop the same evnt will be drawn and you will have the chance to stop.

    Mike...

  • How to handle errors in my reminder of failure stage post? The reminder post step runtime error will not work with the reminder of failure stage Post

    Hello

    I use post step reminder of failure to manage failures in my sequence. The sequence of reminder post not failure has many steps inside. I realized that other reminders like post step runtime error reminder and Post result list enrty do not work to get the stage Post failure callback procedure. Any suggestions for the error handling in the reminder of failure stage post?

    I also generate a report for the steps in the reminder of failure stage post. How can I do this?

    Thank you

    Yvette

    Thanks for your reply. I use developed approach for reporting. I uses the property Locals.Resultlist of the recall of step seq file post failed to accumulate the results and have a LabVIEW VI in the Group of the cleanup step to remove the results of the local population. List results and writing in an excel file.

    Thank you

    Yvette

  • How to pass parameter in cursor loop for?

    Hi Experts,

    I want to pass the parameter l_bom_header_tbl (i) .assembly_item_name in the statement below how to do this?
    for j from 1... l_bom_components_tbl. COUNTING LOOP
    Thank you

    You can just refer to the variable - it is still in scope. There is no 'good' to make.

  • How to use visa write in loop for

    Hello

    I'm developing a measurement with labview system. I need to write the entry within the loop and then out of the loop he supposed to read the voltage level of the analog input pin. But the problem is, out of loop is 1 table D, so when I put the entry visa within the loop, exit loop wire VISA is also table 1 d. Please help me. Should I supposed to do?

    Change of your loops of connections to register and you don't build a table or errors or resources from visa.

    /Y

  • How to fix error 0 x 80070424 for Windows xp

    can not update using automatic or manual program procedure.all installed in my computer also disappeared. Connect to internet

    can not update using automatic or manual program procedure.all installed in my computer also disappeared. Connect to internet

    80070424 means that a required service is not present or running.

    First of all, make sure that all your personal data and Setup files are saved in one directory other than your computer, as soon as POSSIBLE.

    What's next for security/antivirus installed; is it's subscription and current definitions; has whatever it is detected the last time that the system has been scanned with it?

    Please run this tool Kaspersky to see if it is "hid" software malware present - How to remove malware belonging to the family Rootkit.Win32.TDSS

    If TDSSKiller.exe does not detect anything, then suggest you try to download and use the scan of Microsoft Security
    If the safety of MS Scanner cannot be downloaded or run, then try to do a scan online - ESET Online Scanner

    IF you still can not use all that above, then suggest you use another computer to burn a rescue CD which will be that you will be able to your computer so that the hard disk is not active-

    How to create a BitDefender rescue CD
    or
    Kaspersky Rescue Disk 10

    If you can scan the system and no malware has been detected, then the problem may be that your user account is damaged or there is serious integrity with XP - problems

    How to copy data from a corrupted to a new profile in Windows XP user profile  
    How to perform a Windows XP repair install

  • How to fix error code windows 641 for the Vista updates?

    Update failed for the update to Service Pack 1.

    Hello

    Thank you to contact Microsoft Community and we will be happy to help you with your concern.

    According to the description, you can not install Windows Vista SP1.

    This problem can be solved by running a scan of the System File Checker.

    Method 1: download and install the Windows Vista SP1 manually and check if it helps.

    For Windows Vista 32-bit SP1:

    http://www.Microsoft.com/en-in/Download/details.aspx?ID=30

    For Windows Vista SP1 64-bit:

    http://www.Microsoft.com/en-in/Download/details.aspx?ID=21299

    Method 2: Perform the steps from the link below and see if it helps.

    How to resolve problems connecting to Windows Update or Microsoft Update

    Hope this information helps.

    Answer to us if you have problems with Windows Update or any other issue of Windows, and we would be happy to help you.

    Good day!

  • How to handle parsing JSON with Java for String and String []?

    I have a string of JSON (sample) as follows and I created a POJO Mapper using Jackson to manage the same, but as I saw the data I noticed the problem mentioned

    How should I treat the underside of change of the data of String() string in my class Mapper POJO of ideas would be helpful

    < code >

    @JsonIgnoreProperties(ignoreUnknown = true)
    public class Ref implements Serializable {
    
    @JsonProperty("BBT")
      private String BBT;
    
    .... more code here
    
    
    
    //Sample 1
    "Ref": {
          "ISN": "AEBDC44",
          "CCD": "213128908338",
          "BGID": "XCAS3213213",
          "BBS": "23123123",
          "BBT": "CCC",
          "WRT": "POP91230",
          "SDL": "290123",
          "BUN": "ZZRET10PV4",
          "BCSP": "ZZRET10PV4",
          "CSP": "ZZRET10PV4"
        }
    
    //Sample 2
    "Ref": {
          "ISN": "AEBDC44",
          "CCD": "213128908338",
          "BGID": "XCAS3213213",
          "BBS": "23123123",
          "BBT": ["CCC","AAA"],         //Sometimes recevied as an String array instead of String
          "WRT": "POP91230",
          "SDL": "290123",
          "BUN": "ZZRET10PV4",
          "BCSP": "ZZRET10PV4",
          "CSP": "ZZRET10PV4"
        }
    

    < code >

    Found the solution.

    Thank you seems in any case this forum is not very active over after stackoverflow etc. dominating the WRT forums programming and all

    In the case of some1 should

    Change return type

    Converted to object.

  • How-to - change 'Statement CASE in LOOP FOR' to 'FORALL statement?

    deleted

    Ah ok, so your data looks like for each order_id there will be 10 rownumber (1.10). In this case, you will need to rotate the table dt_info, and then perform the merge.

    This gives a test

    merge into export_local_order elo
    a_l'_aide_de)
    Select order_id
    , max (decode (rownumber, 1, aggregated_id |)) ' ' || aggregated_text)) Aggregated_group_downtime_1
    , max (decode (rownumber, 2, aggregated_id |)) ' ' || aggregated_text)) Aggregated_group_downtime_2
    , max (decode (rownumber, 3, aggregated_id |)) ' ' || aggregated_text)) Aggregated_group_downtime_3
    , max (decode (rownumber, 4, aggregated_id |)) ' ' || aggregated_text)) Aggregated_group_downtime_4
    , max (decode (rownumber, 5, aggregated_id |)) ' ' || aggregated_text)) Aggregated_group_downtime_5
    , max (decode (rownumber, 6, aggregated_id |)) ' ' || aggregated_text)) Aggregated_group_downtime_6
    , max (decode (rownumber, 7, aggregated_id |)) ' ' || aggregated_text)) Aggregated_group_downtime_7
    , max (decode (rownumber, 8, aggregated_id |)) ' ' || aggregated_text)) Aggregated_group_downtime_8
    , max (decode (rownumber, 9, aggregated_id |)) ' ' || aggregated_text)) Aggregated_group_downtime_9
    , max (decode (rownumber, 10, aggregated_id |)) ' ' || aggregated_text)) Aggregated_group_downtime_10
    , max (decode (rownumber, 1, local_id)) local_id_downtime_1
    , max (decode (rownumber, 2, local_id)) local_id_downtime_2
    , max (decode (rownumber, 3, local_id)) local_id_downtime_3
    , max (decode (rownumber, 4, local_id)) local_id_downtime_4
    , max (decode (rownumber, 5, local_id)) local_id_downtime_5
    , max (decode (rownumber, 6, local_id)) local_id_downtime_6
    , max (decode (rownumber, 7, local_id)) local_id_downtime_7
    , max (decode (rownumber, 8, local_id)) local_id_downtime_8
    , max (decode (rownumber, 9, local_id)) local_id_downtime_9
    , max (decode (rownumber, 10, local_id)) local_id_downtime_10
    , max (decode (rownumber, 1, local_text)) local_text_downtime_1
    , max (decode (rownumber, 2, local_text)) local_text_downtime_2
    , max (decode (rownumber, 3, local_text)) local_text_downtime_3
    , max (decode (rownumber, 4, local_text)) local_text_downtime_4
    , max (decode (rownumber, 5, local_text)) local_text_downtime_5
    , max (decode (rownumber, 6, local_text)) local_text_downtime_6
    , max (decode (rownumber, 7, local_text)) local_text_downtime_7
    , max (decode (rownumber, 8, local_text)) local_text_downtime_8
    , max (decode (rownumber, 9, local_text)) local_text_downtime_9
    , max (decode (rownumber, 10, local_text)) local_text_downtime_10
    , max (decode (rownumber, 1, event)) events_downtime_1
    , max (decode (rownumber, 2, event)) events_downtime_2
    , max (decode (rownumber, 3, event)) events_downtime_3
    , max (decode (rownumber, 4, event)) events_downtime_4
    , max (decode (rownumber, 5, event)) events_downtime_5
    , max (decode (rownumber, 6, event)) events_downtime_6
    , max (decode (rownumber, event 7,)) events_downtime_7
    , max (decode (rownumber, 8, event)) events_downtime_8
    , max (decode (rownumber, 9, event)) events_downtime_9
    , max (decode (rownumber, 10, event)) events_downtime_10
    , max (decode (rownumber, 1, formatfunctions.days_to_time (total_time))) Total_duration_downtime_1
    , max (decode (rownumber, 2, formatfunctions.days_to_time (total_time))) Total_duration_downtime_2
    , max (decode (rownumber, 3, formatfunctions.days_to_time (total_time))) Total_duration_downtime_3
    , max (decode (rownumber, 4, formatfunctions.days_to_time (total_time))) Total_duration_downtime_4
    , max (decode (rownumber, 5, formatfunctions.days_to_time (total_time))) Total_duration_downtime_5
    , max (decode (rownumber, 6, formatfunctions.days_to_time (total_time))) Total_duration_downtime_6
    , max (decode (rownumber, 7, formatfunctions.days_to_time (total_time))) Total_duration_downtime_7
    , max (decode (rownumber, 8, formatfunctions.days_to_time (total_time))) Total_duration_downtime_8
    , max (decode (rownumber, 9, formatfunctions.days_to_time (total_time))) Total_duration_downtime_9
    , max (decode (rownumber, 10, formatfunctions.days_to_time (total_time))) Total_duration_downtime_10
    of dt_info
    where request_id = lv_request_id
    and rownumber in (1,2,3,4,5,6,7,8,9,10)
    Group
    by order_id
    ) dt
    on)
    Elo.request_id = lv_request_id and
    Elo.order_id = dt.order_id
    )
    When matched then
    Update
    SET Aggregated_group_downtime_1 = dt. Aggregated_group_downtime_1
    Local_ID_downtime_1 = dt. Local_ID_downtime_1
    Local_text_downtime_1 = dt. Local_text_downtime_1
    Total_duration_downtime_1 = dt. Total_duration_downtime_1
    Events_downtime_1 = dt. Events_downtime_1
    Aggregated_group_downtime_2 = dt. Aggregated_group_downtime_2
    Local_ID_downtime_2 = dt. Local_ID_downtime_2
    Local_text_downtime_2 = dt. Local_text_downtime_2
    Total_duration_downtime_2 = dt. Total_duration_downtime_2
    Events_downtime_2 = dt. Events_downtime_2
    Aggregated_group_downtime_3 = dt. Aggregated_group_downtime_3
    Local_ID_downtime_3 = dt. Local_ID_downtime_3
    Local_text_downtime_3 = dt. Local_text_downtime_3
    Total_duration_downtime_3 = dt. Total_duration_downtime_3
    Events_downtime_3 = dt. Events_downtime_3
    Aggregated_group_downtime_4 = dt. Aggregated_group_downtime_4
    Local_ID_downtime_4 = dt. Local_ID_downtime_4
    Local_text_downtime_4 = dt. Local_text_downtime_4
    Total_duration_downtime_4 = dt. Total_duration_downtime_4
    Events_downtime_4 = dt. Events_downtime_4
    Aggregated_group_downtime_5 = dt. Aggregated_group_downtime_5
    Local_ID_downtime_5 = dt. Local_ID_downtime_5
    Local_text_downtime_5 = dt. Local_text_downtime_5
    Total_duration_downtime_5 = dt. Total_duration_downtime_5
    Events_downtime_5 = dt. Events_downtime_5
    Aggregated_group_downtime_6 = dt. Aggregated_group_downtime_6
    Local_ID_downtime_6 = dt. Local_ID_downtime_6
    Local_text_downtime_6 = dt. Local_text_downtime_6
    Total_duration_downtime_6 = dt. Total_duration_downtime_6
    Events_downtime_6 = dt. Events_downtime_6
    Aggregated_group_downtime_7 = dt. Aggregated_group_downtime_7
    Local_ID_downtime_7 = dt. Local_ID_downtime_7
    Local_text_downtime_7 = dt. Local_text_downtime_7
    Total_duration_downtime_7 = dt. Total_duration_downtime_7
    Events_downtime_7 = dt. Events_downtime_7
    Aggregated_group_downtime_8 = dt. Aggregated_group_downtime_8
    Local_ID_downtime_8 = dt. Local_ID_downtime_8
    Local_text_downtime_8 = dt. Local_text_downtime_8
    Total_duration_downtime_8 = dt. Total_duration_downtime_8
    Events_downtime_8 = dt. Events_downtime_8
    Aggregated_group_downtime_9 = dt. Aggregated_group_downtime_9
    Local_ID_downtime_9 = dt. Local_ID_downtime_9
    Local_text_downtime_9 = dt. Local_text_downtime_9
    Total_duration_downtime_9 = dt. Total_duration_downtime_9
    Events_downtime_9 = dt. Events_downtime_9
    Aggregated_group_downtime_10 = dt. Aggregated_group_downtime_10
    Local_ID_downtime_10 = dt. Local_ID_downtime_10
    Local_text_downtime_10 = dt. Local_text_downtime_10
    Total_duration_downtime_10 = dt. Total_duration_downtime_10
    Events_downtime_10 = dt. Events_downtime_10

  • In practice, how do you handle errors?

    This issue arises out of a project I've been working on a database. Customers pull a work from a database, run it, and then post the results in the database. I have a prototype that does well enough, with the exception of a few questions (which can be written in chalk upward at the bad design).

    The first concerns the race conditions: when a customer takes a job from the database, it has first checks the task settings, then updates the status of the work to 'Running', how much work can be pulled by another customer. The race condition occurs when two customers to get the same work and are trying to insert the results of the work of the same in the table of results (primary key error). I intend to add a phase "pending" to avoid this problem.

    A second comes when the DB goes down, for some reason any. It's on a laptop, so downtime is planned on the occasion, but these errors are more difficult to propose a strategy to correct.

    Now that you see a bit where I come from, the main question.

    How you guys set up the error handling?

    I thought using a construction like this:

    The basic idea is to fall more and deeper structures in case Error-No error and handle errors constantly running the code in a while loop until we get no error. The problem with this approach is that a lack of support for recursion makes this code very very messy. I'm not sure how to determine which codes for a set of uses of screws, in order to make the correct handling of cases for each of them.

    I understand the importance of the management of errors and get the base implementation of this one, so the docs NOR and Sixclear videos are too simplistic. What I would like to find is a depth into the constructions of error management resource. Is there such a thing?

    Take a look at the attached PDF - it shows a fairly comprehensive list of how to handle errors in a loop/application.

    It does not cover the things that you can do with indicate error as the user, logs the error etc.

    What you are actually doing is strongly dependent on your application!

  • How can I distribute randomly addition or subtraction in a loop for?

    Someone at - it ideas for how can I randomly assign a loop for to add or subtract from the random numbers throughout the various itterations?  My current code generates two random numbers and added together for a number of itterations.  I need a few itterations randomly to be subtraction.  Thanks in advance!

    Add another random number generator and compare the result against 0.5. Use a case around your addition/subtraction operator.

    Looks like you might also want to exit what operation is in fact taken.

Maybe you are looking for