Transaction control statements in loop

for i in p_time_duration_rspm_spm.first..p_time_duration_rspm_spm.last
loop
insert into green.solids_aaqm_namp(sample_nr,time_duration_rspm_spm,monometer_reading,
     avg_flow,total_sampling_period,vol_air_sampled,
                         filter_paper_nr,cup_nr)
               values(p_sample_nr,p_time_duration_rspm_spm(i),
                    p_monometer_reading(i),p_avg_flow(i),
                    p_total_sampling_period(i),p_vol_air_sampled(i),
                    p_filter_paper_nr(i),p_cup_nr(i));
end loop;
hallo,
i am facing a problem in the insert statement.There is a table(3*6).the fields in the table are
of number datatype.if any character is entered in any of those field a error message as to be
displayed.
and if a character is entered into second row, then the readings in the first row is inserted
in to the table and then a error message is prompted.i want to know whether can we use the transaction control statements
within the loop to avoid inserting only one row.if so, how?...is there any other way to implement the same at the form level
before going the database.

Hello,
FORALL i in p_time_duration_rspm_spm.first..p_time_duration_rspm_spm.last SAVE EXCEPTIONS
insert into green.solids_aaqm_namp(sample_nr,time_duration_rspm_spm,monometer_reading,
avg_flow,total_sampling_period,vol_air_sampled,
filter_paper_nr,cup_nr)
values(p_sample_nr,p_time_duration_rspm_spm(i),
p_monometer_reading(i),p_avg_flow(i),
p_total_sampling_period(i),p_vol_air_sampled(i),
p_filter_paper_nr(i),p_cup_nr(i));
end loop;
If wants Errors then
errors := SQL%BULK_EXCEPTIONS.COUNT;
dbms_output.put_line('Number of DELETE statements that failed: ' || errors);
FOR i IN 1..errors LOOP
dbms_output.put_line('Error #' || i || ' occurred during '||
'iteration #' || SQL%BULK_EXCEPTIONS(i).ERROR_INDEX);
dbms_output.put_line('Error message is ' ||
SQLERRM(-SQL%BULK_EXCEPTIONS(i).ERROR_CODE));
END LOOP;
OR You can use as follows
for i in p_time_duration_rspm_spm.first..p_time_duration_rspm_spm.last
loop
begin -- Newline Added
insert into green.solids_aaqm_namp(sample_nr,time_duration_rspm_spm,monometer_reading,
avg_flow,total_sampling_period,vol_air_sampled,
filter_paper_nr,cup_nr)
values(p_sample_nr,p_time_duration_rspm_spm(i),
p_monometer_reading(i),p_avg_flow(i),
p_total_sampling_period(i),p_vol_air_sampled(i),
p_filter_paper_nr(i),p_cup_nr(i));
EXCEPTION when OTHERS then -- Newline Added
null; -- Newline Added
end; -- Newline Added
end loop;
Bye
Chitta

Similar Messages

  • Transactional control statements in trigger

    Hi,
      Transaction Control statement, which cannot be executed within a trigger body??why...explain with reason
    its helpful me..

    Ishan wrote:
    "a way you can actually make it work" .... seriously?
    Yes, I was serious. Why? What's wrong with that? Technically speaking, won't it work?
    This is not a way to make it work, it's a way to break an application/process
    Well !!! All the cases?
    Here's  a scenario
    I want to audit a table where if any change done by the user has to be tracked in an audit table, irrespective whether the change has now been rolled back in the main table. I want to see what change was done? How would I do it? Going by your logic of breaking application/process, I should never use trigger as  AUTONOMOUS_TRANSACTION. Am I right? How would I achieve it now?
    Your auditing/tracing code should be in a separate procedure and that procedure should be autonomous, so that the requirement to write autonomous data for that purpose is kept isolated from the trigger code.  Consider this scenario instead.  You want to write audit/trace information from your triggers, so you make the trigger autonomous and put in your code to write the audit/trace information.  Later on, someone who hasn't a clue comes along and decides they need to do something else in that trigger (well why write a new trigger when one already exists?) and they get it to write some data in relation to the data being created by the trigger.  Now you suddenly have a transactionally unsafe application, where this 'child data' can still be written and committed even if there's a problem in the main transaction.  By isolating auding/tracing away to it's own autonomous procedure, you make it clear that it's only the auditing/tracing that should be autonomous and prevent any problems from occuring inside the trigger itself.
    That's more of a way to write bad code that is transactionally unsafe and demonstrates a lack of understanding of database transactional processing or how the rdbms on the server processes commits and could potentially lead to write contention in the writer processes, of which many would be spawned if the number of inserts (in this example) was high.
    The above comment is based on the assumption(which, I never stated) that in whatever scenario my code would be implemented, it would ALWAYS break the process. There are scenarios where this code could be required.
    Here's a link from Oracle Documentation, that uses an example of creating a trigger with AUTONOMOUS_TRANSACTION. If it is a so bad example which "demonstrates a lack of understanding of database transactional processing", why would Oracle even mention it in their documentation?
    http://docs.oracle.com/cd/B19306_01/appdev.102/b14261/sqloperations.htm#BABDHGAB
    And the answer is because there is a way to do it and it could actually be required, even though it's rare.
    I just showed OP, that it's not allowed directly and if required, it can be done as there is a way to do it. When to do it and what could be the consequences was never the scope of the question.
    Yes, and there's ways to jump off cliffs and kill youself, but I wouldn't recommend demonstrating how to do that to people just because it's possible.
    Just because it's in the oracle documentation doesn't always mean it's best practice.  A lot of the documentation was written a long time ago and best practices have changed as well as further functionality added, and Oracle has been known to make mistakes in their documentation too.  However in this example, it's using it for auditing purposes, so the idea was almost there, but they still haven't met best practices of keeping the auditing isolated, so their example is not the best.

  • Control statements in  loop s with where cond

    Hi All,
    I am using control statements in the loop which as where condition  , The program works fine but , there is warning message , Is it appropriate to still use .
    Thanks in advance
    Vinay

    below is the code .
    LOOP AT gt_data_table INTO gs_data_table WHERE cust IN s_cust
                                                  AND site IN s_plant
                                                  AND acc_grp = gv_acc_grp
                                                  AND commodity IN s_commd
                                                  AND season IN s_season.
          lv_partial_stk =  lv_partial_stk  +  gs_data_table-available_stk.
          lv_over_stk    =  lv_over_stk     +  gs_data_table-available_stk.
          IF NOT gs_data_table-available_stk IS INITIAL.
            APPEND gs_data_table TO gt_data_table1.
          ENDIF.
          lv_cust       =  gs_data_table-cust.
          lv_commodity  = gs_data_table-commodity.
          lv_season     = gs_data_table-season.
          AT END OF lv_str1 .
            IF gs_data_table-site_typ      = 'COUNTRY'.
              gs_cust_cntry_stk-cust        = gs_data_table-cust .
              gs_cust_cntry_stk-commodity   = gs_data_table-commodity.
              gs_cust_cntry_stk-season      = gs_data_table-season.
              gs_cust_cntry_stk-cntry_stk   = lv_partial_stk.
              APPEND gs_cust_cntry_stk TO gt_cust_cntry_stk.
            ENDIF.
            IF gs_data_table-site_typ     = 'PORT'.
              gs_cust_port_stk-cust       = gs_data_table-cust .
              gs_cust_port_stk-commodity  = gs_data_table-commodity.
              gs_cust_port_stk-season     = gs_data_table-season.
              gs_cust_port_stk-port_stk   = lv_partial_stk.
              APPEND gs_cust_port_stk TO gt_cust_port_stk.
            ENDIF.
            CLEAR lv_partial_stk.
          ENDAT.
          AT END OF lv_str.
            gs_cust_overall_stk-cust         = lv_cust.
            gs_cust_overall_stk-commodity    = lv_commodity.
            gs_cust_overall_stk-season       = lv_season.
            gs_cust_overall_stk-overall_stk  = lv_over_stk .
            CLEAR lv_over_stk.
            APPEND gs_cust_overall_stk TO gt_cust_overall_stk.
          ENDAT.
        ENDLOOP.
    Thanks Guys
    vinay

  • Control structure in loops.

    I want to do something like below done in Perl in Pl/Sql but am not getting to it.
    # Perl code
    while($i <5)
    ... DO SOMETHING
    if ($i == 3)
    # means that start the loop again with $i = 4.
    next;
    # The following lines will be skipped when the value of $i will be 3
    ... DO SOMETHING
    $i++;
    Similarly,
    I have some cursor in pl/sql and I open a loop.
    -- Pl/SQl code
    for rec in cursor_records loop
    ... DO SOMETHING
    if( rec.my_val = 3) then
    -- now, what is the control statement do i need to give here, similar to above like next.
    -- Means, when value of rec.my_val is 3, then the lines following the if loop will get
    -- skipped and loop will continue for value 4.
    end if;
    ... DO SOMETHING
    end loop;
    Thanks..

    Thanks all for their replies.
    Looks like we don't have a way something like next/continue in Pl/Sql.
    hi Dave,
    I cannot use the approach you have said in the first reply as
    if you closely see my code, I have DO_SOMETHING before the check condition
    and have DO_SOMETHING again after the check condition.
    Your reply1, solves if only I have DO_SOMETHING2, and not DO_SOMETHING1.
    hi Leo,
    I see two loops as an overhead and I really do not prefer this approach.
    There can be a case when when a cursor is taking sometime to fetch a million records
    from billions of records and then act on them.
    In such a case, running two of them is really an overhead.
    I think that I will have to live with <<GO_TO>> option.
    Anywz, Thanks all for their replies and their effort.

  • Control statement in internal tables

    hi experts,
    can any body will provide me the control statement of internal table.
                                                               thank you

    Hi,
    check this link
    http://help.sap.com/saphelp_nw2004s/helpdata/en/9f/db9f1f35c111d1829f0000e829fbfe/content.htm
    Control Break Statements
    Control break statements are used to create statement blocks which process only specific table lines the LOOP – ENDLOOP block.
    You open such a statement block with the control level statement AT and close it with the control level statement ENDAT. The syntax is as follows:
    Table should be sorted when you use control-break statements
    You can break the sequential access of internal tables by using these statements.
    Syntax:
    At first.
    <Statement block>
    Endat.
    This is the first statement to get executed inside the loop (remember control break statements are applicable only inside the loop)
    So in this block you can write or process those statements which you want to get executed when the loop starts.
    At New carrid.
    Write:/ carrid.
    Endat.
    In this case whenever the new carrid is reached, carrid will be written.
    At End of carrid.
    Uline.
    Endat.
    In this case whenever the end of carrid is reached, a line will be drawn.
    At Last.
    Write:/ ‘Last Record is reached’.
    Endat.
    Processing of statements within this block is done when entire processing of entire internal table is over. Usually used to display grand totals.
    You can use either all or one of the above control break statements with in the loop for processing internal table.
    At end of carrid.
    Sum.
    Endat.
    In above case the statement SUM (applicable only within AT-ENDAT) will sum up all the numeric fields in internal table and result is stored in same internal table variable.
    Regards,
    Sruthi

  • Control statements

    When using control statements like AT FIRST...ENDAT.AT NEW (field).... ENDAT.
    Is it necessary to define the field (thru which we r going to group the records) as a first field in internal table?

    Hi,
         Control break statements are used to stop the control at a particular point.
    1. AT NEW f.
    2. AT END OF f.
    3. AT FIRST.
    4. AT LAST.
    Effect
    In a LOOP which processes a dataset created with EXTRACT , you can use special control structures for control break processing. All these structures begin with AT and end with ENDAT . The sequence of statements which lies between them is then executed if a control break occurs.
    You can use these key words for control break processing with extract datasets only if the active LOOP statement is proceesing an extract dataset.
    The control level structure with extract datasets is dynamic. It corresponds exactly to the sort key of the extract dataset, i.e. to the order of fields in the field group HEADER by which the extract dataset was sorted .
    At the start of a new control level (i.e. immediately after AT ), the following occurs in the output area of the current LOOP statement:
    All default key fields (on the right) are filled with "*" after the current control level key.
    All other fields (on the right) are set to their initial values after the current control level key.
    Between AT and ENDAT , you can use SUM to insert the appropriate control totals in the number fields (see also ABAP/4 number types ) of the LOOP output area (on the right) after the current control level key. Summing is supported both at the beginning of a control level ( AT FIRST , AT NEW f ) and also the end of a control level ( AT END OF f , AT LAST ).
    At the end of the control level processing (i.e. after ENDAT ), the old contents of the LOOP output area are restored
    use control break on any fields
    chk this sample program
    REPORT YCHATEST LINE-SIZE 350.
    TABLES MARA.
    DATA : BEGIN OF ITAB OCCURS 0,
             MATNR LIKE MARA-MATNR,
             AMOUNT TYPE P DECIMALS 2,
           END OF ITAB.
    ITAB-MATNR = '12345'.
    ITAB-AMOUNT = '100.20'.
    APPEND ITAB.
    CLEAR ITAB.
    ITAB-MATNR = '12345'.
    ITAB-AMOUNT = '100.20'.
    APPEND ITAB.
    CLEAR ITAB.
    ITAB-MATNR = '3456'.
    ITAB-AMOUNT = '100.20'.
    APPEND ITAB.
    CLEAR ITAB.
    sort itab by matnr amount.
    LOOP AT ITAB.
      AT END OF AMOUNT. 
        WRITE : / ITAB-MATNR , ITAB-AMOUNT.
      ENDAT.
    ENDLOOP.
    Regards

  • Table controls and step loops

    what are the differances between table controls and step loops?

    Hi
    It's only graphic diff. managed by diff. ways (of course):
    in steploop there isn't a table control so in PBO and PAI it has only the stataments LOOP/ENDLOOP or LOOP AT ITAB/ENDLOOP.
    The step loop is way older than table control to display the data of a table.
    check this
    Re: step loops, table controls
    -charitha.

  • How can I make a control inside a loop in a subVI change value when the calling VI's control changes?

    Hi.
    I think this is a pretty basic LV question, but I have not been able to find a good solution.
    I am attaching VIs that show the problem I am having, but obviously, the real application is a lot complicated, which forces me to try to do it this way.
    The issue is: I have a subVI with a Boolean control inside a loop.  When the control is true I want some action to take place.  When the subVI is run on its own, it works fine, acting properly when I set the boolean control to true via the LV FPGA interface from the host.  However, when I use it as a subVI, in which the top-level VI calls several instances of the subVI, I have the Boolean controls in the top level VI.  What is happening is that the false Boolean value with which the top-level VI starts is passed into the subVIs, and not updated, even though the control is inside the loop.
    Can any one suggest a good solution?
    Thanks,
    AlejandroZ
    Attachments:
    CallingVI.vi ‏7 KB
    subVI.vi ‏8 KB

    Hi.
    I know the example I posted might seem silly, but it was just to illustrate the problem I am having.  In reality this is the application:
    I have some LV FPGA code which uses a few FPGA IO to implement a serial link to communicate with a device.  Most of the time we are getting data from the device, so the serial link is used to send a read command, read in the data and put it into a FIFO.  However, I also wanted the VI to support sending data to the device, so I added an array control to put the data you want to send, and a boolean control to tell it you want to send it.
    Since sending and receiving data are done using the same FPGA IO, they cannot be independent operations, because they would garble each other. Therefore, in the subVI I have a loop in which I first read data if there is any to read, then check the boolean write control to see if there is data to write.
    As I mentioned, this works perfectly for talking to a single device.  However, we run into the issue of this topic when trying to replicate this for several devices.
    One easy solution is to not have the loop in the subVI, and have it in the calling VI (I am favoring this simple solution right now).  The only reason why I have not done this yet, is that the subVI has more than one loop, so I am going to have to create several subVIs.  I just posted to see if there was an even simpler solution...
    There have been some other possibly good solutions proposed here, though I am not sure if they work in LV FPGA.
    Thanks for all your responses.
    AlejandroZ

  • Business Transaction control based on equipment status

    I have created status profile  for equipment creation . One of the user status is "Created by User" . Now If the user status of the equipment is this , I  want  to disallow notification creation through iw21 on this equipment .
    Please explain in detail how to achieve this through transaction control in status profile (I have already tried object type "maintainence notif " etc in status profile ....but did not find transaction create notification which has to be forbidden .)..
    Also please explain how to view transaction code along with business transaction in transaction control screen ..(any alternate way ?)
    NPB

    hi
    kindly specify the object type as Equipment and check
    I am not sure, kindly mark the Create Log Notification as forbidden for the user status
    regards
    thyagarajan

  • Business Transaction Control is not Working for Equipment Status.

    Hi All,
    I have created a Status Profile for Equipment / Functional Location & assigned 5 Status under this Profile i.e. NEW, COM (Commissioning), INS(Inservice), CAM (Care & Maintenance) & DCM (De Commissioned). For Status DCM i have assigned Transaction control FORBIDDEN for "Enter PM processing data , Enter PM planing data & Create Meas. Doc."activities.
    It Means, whenever user creates Plant Maintenance Order OR Notification, Maintenance Plan OR Maintenance Item & Measurement Document for any Equipment / FL having this user status (DCM), system should not allow creation of above mentioned object.
    In my scenario, system is giving an standard error message " The business transaction cannot be carried out" during creation of "Plant Maintenance Order OR Notification, Maintenance Plan OR Maintenance Item".
    But i am able to create measurement document for equipment / FL having user status DCM with Transaction control Forbidden of Measurement document creation. No error message displayed by the system.
    Can anybody tell me why its happening? Why system is giving error during order & plan creation but not for Creation of measurement document ?
    If this is not posible in standard SAP, does any body knows about any OSS note so that we can implement the same to get an error message.
    Thanks in advance
    Arun

    Please ensure whether both projects have the same budget profile. Other than that you need to carefully investigate how the cost was posted onto both projects in the first place. Please note in case of procurements, budget is only checked at the commitments level (search the forum as this has been discussed before).
    In case this does not resolve your issue, revert back with the budget profile settings.
    Regards,
    Ammar

  • Is there a way to make state transitions/animations of a fl.control states - button for example ?

    Is there a way to make state transitions/animations of a fl.control states - button for example ?
    All I can do now is change the skin design and that's it, I can't animate between states like I can with Flash Builder skins. So is there a way to do that, any technique or I have to create a button component from scratch?
    Thanks!

    simplebuttons have upState etc properties you can use to assign movieclips to the 3 states.  you can use the currentFrame property of movieclps to (appear to) smoothly transition from one state to another.

  • How to use Fuzzy Logic Controller for transfer function in labview control and simulation loop?

    I am facing problem with fuzzy PD logic controller for transfer function in control and simulation loop.
    Plz Help me in this regard...................
    i have attache snapshot of my program
    Attachments:
    fuzzy in simulation loop.JPG ‏52 KB

    Hi Sankhadip,
    Sorry for the late response. I was looking at your code and
    I noticed that the graph scale does not start from zero. That might be the
    reason why you don't see the transient in the simulation. To change the scales
    simply double click on the lower limit and set it to zero. If this is not the
    expected results, can you please post the expected results, so we can see what are the
    differences between the results . Also, you might be using different
    solvers, and that gives different results as well.    
    Thanks and have a great day.
    Esmail Hamdan | Applications Engineering | National
    Instruments

  • Configuring toplink with EJB to transactional control "CMT"

    I try to use the EJB transaction CMT but I need to configure toplink to use a transactional control of my EJB container. some body knows how can i do this? and how can I configure the toplink to get JNDI datasource?
    Best Regards

    I dont think there is anything in Toplink you need to configure for CMT. All the transactional attributes are specified in the ejb-jar.xml file and I dont think you can edit this file using the Workbench or the Sessions Editor. With CMP the Workbench gives you an option to either overwrite this file or update but there is no way to "update" for transactional attributes. You can look at the examples for CMP (under folder advanced) that shows you how to use entity beans with Toplink in a CMP environment and you can look at the ejb-jar.xml file for more information.
    Configuring Toplink to get JNDI data source is easy-thats defined in the sessions.xml. Just open the sessions.xml using the sessions editor and click on login tab and then enter in the data source information.
    I try to use the EJB transaction CMT but I need to
    configure toplink to use a transactional control of
    my EJB container. some body knows how can i do this?
    and how can I configure the toplink to get JNDI
    datasource?
    Best Regards

  • How to handle transaction control--- in the dbms query or in JDBC? or BOTH?

    Hi all,
    we have a servlet application which do insert, update to a few sybase tables. so far we don't have any transaction management control in either store procedure or in JDBC call. i like to know where should we enforce this control logic? in both place or either one is enough?
    thanks!!

    according to your answer, is it safe to say that we
    should NOT
    handle transaction control in both query and JDBC
    call? i am on the side of JDBC
    program control. However our manager feels that if we
    handle it in two place, we could be more error-proof.
    i don't know how to convince him that only one place
    could make it work. Double your rollbacks double your fun! Odd that a manager is getting involved at this level...
    Providing transaction control at both places, as a rule makes absolutely no sense at all (to me). I actually believe that this would be far more error-prone (not error-proof). It's really a logistics issue. When you are working on the Java code, you won't have the stored procedure(s) code right there. While you may design it masterfully at first, as maintenance occurs, the mastery can easily be lost as assumptions are made on when and where commit or rollback processing is going to take place. The end result would be a system that could easily corrupt the logical integrity of the database.
    If you have to make a decision up front, and you believe performance will ultimately be a concern, then your decision should be to handle transaction management within the stored procedure(s). However, this decision will make the stored procedures far more complex than what the DBA or application staff is familiar with. You would also have to take some care to release resources as appropriate within the Java code.
    If you decide to manage transactions within JDBC, it is possible that you will have to move a portion of transaction managment to one or two of the stored procedures. This would be a 'fix' for a poorly performing functionality, and you would simply take care to limit this as much as possible.
    I wish I could guide you specifically, but I'm working at 20,000 feet related to your specific application needs.

  • External transaction control and ability to find new registered objects

    Hello, We are using Toplink with external transaction control and have a process inserting a complex hierarchy of objects. During the process we either do a registerObject or deepmergeClone depending on if the instance is already in the db. With external transaction control the registerObject does not actually do the commit to db until the global transaction (Container) issues the commit. Unfortunately we end up doing creating multiple instances of same objects ( because the assumption that registerObject would have written the row to the db ) with the same keys and when the container issues the commit we end up with duplicate key violation. Is there a way to find out if an object with a particular key is already registered?

    This sounds like the kind of question that can only be answered with a whiteboard and a good review of your architecture.
    In general, there should be no problem registering objects multiple times. I.e.,
    x = some object
    x1 = uow.registerObject(x);
    Then x1==uow.registerObject(x), and x1==uow.registerObject(x1), etc. When you register an object with the UOW, based on PK it'll always return that same one.
    Do you have multiple units of work on the go? (that may explain this behavior).
    In any case, I think the real problem here is that you're somehow registering objects that are no longer cached. I.e., some object is serialized or rebuilt and then registered after it's gone from the cache. By default, TopLink determines if an object is new or existing (to determine INSERT vs UPDATE) by hitting the cache. You can change this default behavior in the Mapping Workbench, open the advanced property for "Identity" and change existence checking to "check database". Although, this can be a slow and tedious process to have to keep hitting the DB.
    A little trick I use sometimes is to take advantage of the "readObject" API that will read the object from the databaes if it's not already in cache, and just return it from cache if it is in cache. Check out the UOW primer at http://otn.oracle.com/products/ias/toplink/index.html for more info, but the jist is that I would do this if I were you:
    x = some object that you're not sure is cached and you want to register in UOW;
    x' = uow.readObject(x);
    IF the object was in cache, you'd get back a working copy, nice and fast. IF it's not in cache, you hit the database, it goes in cache, and you get your working copy. Now you don't have to change the existence checking option which could slow everything down.
    - Don

Maybe you are looking for