PL SQL with multiple inserts, how to continue after exception is raised

Hi,
I have a simple PL SQL function with various inserts. ex:
Insert Into "DI01"."DUA_DIM_UNITE_ADMIN" (Ide_Unite_Admin_Sk, Num_Unite_Admin, Des_Unite_Admin) Values ('-1', '00000000', 'Défaut');
INSERT INTO "DI01"."DUA_DIM_UNITE_ADMIN" (IDE_UNITE_ADMIN_SK, NUM_UNITE_ADMIN, DES_UNITE_ADMIN) VALUES ('-2', 'S. O.', 'Sans Objet');
Insert Into "DI01"."DCU_DIM_CATGR_UNSPS" (Ide_Catgr_Sk, Num_Code, Des_Code, Num_Catgr, Des_C.........
I want to be able to run the function multiple times, and have all the inserts executed everytime, even if I get a ORA-00001 unique constraint (string.string) violated error in on of the inserts. That means that if I get an error in the first insert, I want the function to continue running and executing the consecutive inserts.
I though of including each insert in a different block, like:
BEGIN
Insert......
When Exception then null;
END;
BEGIN
Insert......
When Exception then null;
END;
But I have at least 50 inserts, so the final code becomes huge.
Another solution is to use merge inseat of insert, but the code seems too complex for such a simple task.
Is there any other solution for this that I am not seeing?
Thank you for your time,
Joao Moreira

You can use DML error logging approach or FORALL SAVE EXCEPTIONS.
Since you didn't mention the version I assume you are using 11g.
Below is the sample code for DML error logging mechanism
SQL> select * from v$version;
BANNER                                                                         
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production   
PL/SQL Release 11.2.0.3.0 - Production                                         
CORE 11.2.0.3.0 Production                                                     
TNS for Linux: Version 11.2.0.3.0 - Production                                 
NLSRTL Version 11.2.0.3.0 - Production                                        
SQL> DROP TABLE tableA;
Table dropped.
SQL> DROP TABLE Err$_tableA;
Table dropped.
SQL>
SQL> CREATE TABLE tableA
  2  (
  3     col1   NUMBER PRIMARY KEY,
  4     col2   NUMBER,
  5     col3   VARCHAR2 (10)
  6  );
Table created.
SQL>
SQL> -- Create error log table
SQL>
SQL> BEGIN
  2     DBMS_ERRLOG.create_error_log (dml_table_name => 'TABLEA');
  3  END;
  4  /
PL/SQL procedure successfully completed.
SQL>
SQL> BEGIN
  2     FOR i IN (SELECT 1 AS col1 FROM DUAL
  3               UNION ALL
  4               SELECT 1 FROM DUAL)
  5     LOOP
  6        INSERT INTO tableA (col1)
  7             VALUES (i.col1)
  8                LOG ERRORS INTO Err$_tableA REJECT LIMIT UNLIMITED;
  9     END LOOP;
10 
11     COMMIT;
12  END;
13  /
PL/SQL procedure successfully completed.
SQL> column column_name format a30
SQL> set linesize 300
SQL> select * from tableA;
SQL> select * from err$_tablea;
Thanks,
GPU

Similar Messages

  • When viewing the weather default app with multiple cities, how come there isn't a one click shortcut to go back to the first city?

    When viewing the weather default app with multiple cities, how come there isn't a one click shortcut to go back to the first city?

    3.2 you can make multiple clocks, each clock can have a different alarm.

  • Buddies with multiple IDs: how to message to a specific one?

    Here's a relatively simple problem, on the face of it, that I can't figure out how to solve. Is there in fact a solution?
    I have an increasing number of buddies with multiple IDs (almost always AIM), for instance, one for home and one for work. Because most of them have broadband in both places, they don't shut their computers down in either location and are usually signed in to iChat/AIM in both. I've got their various IDs noted in their cards in Address Book, but in iChat I only see one entry for the person regardless of which ID, or both, is signed in at the moment. There doesn't seem to be much logic to which picture iChat displays along with the entry, so I can't ever tell which ID I am looking at. I know that a mouseover on the iChat entry will tell me the status of all IDs associated with that person, but how can I send a message to the ID that I want?
    Example: buddy is at work and signed in using work ID. Buddy's spouse is at home, also signed in, using home ID. I see one entry for my buddy, showing as active. It might display the home picture and it might display the work picture. If it's the home ID, and open a message window, I'll be messaging with the spouse at home, instead of with my buddy at work -- and I don't see any way to get at the other ID. Is there a way to pick the ID I want to message with?
    I see that I can keep them separate if I create different groups and add each ID, from the same card, to each group. But that's clumsy (as is creating separate cards altogether) and basically removes the meaningfulness of the groups. Is there some obvious trick I am missing, or is what I want to do just not possible?

    Hi Ralph,
    You're exactly right; I need to do the opposite. I suspect it just isn't possible or the solution would be more self-evident. As I mentioned in my original post, the only way I've been able to make it work is to add the IDs separately in iChat and make sure they are added to different groups. Doing this will keep them separate but based on the same Address Book card. In the same group, however, they collapse into one entry and lose their meaning. Unfortunately, keeping separate groups for such a purpose makes the groups essentially meaningless.
    As I would imagine this to be an increasingly common occurrence, this seems to be a definite shortcoming of iChat.
    Thanks for your response.
    Mark

  • Package with multiple inserts

    I am new to packages. I know how to do selects, but not inserts. I need to do inerts to multiple tables. One table I need to do to multiple Inserts. Is there a good example of this anywhere?

    Let me lay this out. There is another piece.
    first table..
    table1id name
    1 cars
    2nd table
    table2id table1id carMake
    1 1 Ford
    2 1 Chevy
    3 1 Honda
    3rd table
    table3id table2id carModel
    1 1 Mustang
    2 1 Tarus
    3 1 F-150
    4 2 Impalla
    5 2 Corvette
    6 2 Caviler

  • Help With Multiple Inserts

    We are running oracl 8i and trying to get this statement to update Unit_warr_test with 20 to 30 lines from the refence table spec_comp_warranty when there is no entries for a given unit_id in the unit_warr_test that matches the unit_main and then matches the spec_no column to the spec_comp_warr table from the unit_main table. Below is the script that we are running. Right now this script returns 85,000,000,000 rows. The spec_comp_warr table only has 46,000 rows in it and the unit_main only has 7,000 rows. there is no reference between spec_comp_warranty table other than the spec_no and each spec has 20 to 30 rows in spec_comp_warranty. Any Ideas on how to get this script to run and insert the 20 30 rows in unit_warr_test when the unit is not in unit_warr_test by matching the spec_no?
    insert into unit_warr_test (COMPONENT,
    DIST_USAGE,
    DURATION,
    EXP_DT,
    EXP_USAGE,
    INVOICE,
    PART,
    TIME_USAGE,
    UNIT_ID,
    U_SYSTEM,
    VENDOR_NO,
    WARR_EXCLUDE_FL,
    RECORD_TYPE,
    ON_WARRANTY_CLAIM,
    POSSIBLE_WARRANTY_CLAIM)
    select
    a.component,
    NULL,
    a.DURATION,
    NULL,
    '0',
    NULL,
    a.PART,
    NULL,
    b.unit_id,
    a.u_system,
    a.vendor_no,
    a.warr_exclude_fl,
    'E',
    'N',
    'N'
    from SPEC_COMP_WARRANTY a, UNIT_MAIN b, UNIT_WARR c
    where b.unit_id <> c.unit_id
    and a.spec_no = b.spec_no and b.spec_no is not null

    It looks like your generating a Cartesian product. Try
    FROM   spec_comp_warranty A, unit_main B
    WHERE   a.spec_no = b.spec_no
    AND    b.spec_no IS NOT NULL
    AND     NOT EXISTS (SELECT c.unit_id
                    FROM  UNIT_WARR c
                    WHERE c.unit_id = c.unit_id )Cheers, APC

  • Please help with multiple insert query into nested table!!!!

    I am having a problem with inserting multiple references to objects into a nested table using the following query:
    INSERT INTO TABLE(SELECT Taken_by FROM courses WHERE course_number= 001)
    (SELECT REF(p) FROM persons p
    WHERE p.enroled_in = 'Computing for Business'
    The database says that p.enroled_in is an invalid identifier. I know why this is. This is because the field enroled_in is part of a subtype of person called student_type and the query above is not accounting for this properly. I would like to know the correct syntax to use so I can insert into the nested table wherever a student is enroled into the 'computing for business' course. My full schema is below:
    CREATE TYPE person_type;
    CREATE TYPE student_type;
    CREATE TYPE staff_type;
    CREATE TYPE course_type;
    CREATE TYPE module_type;
    CREATE TYPE address_type AS OBJECT
    Street VARCHAR2 (30),
    Town     VARCHAR2 (30),
    County VARCHAR2 (30),
    Postcode VARCHAR2 (9)
    CREATE TYPE person_type AS OBJECT
    Name VARCHAR2 (50),
    Address address_type,
    DOB     DATE
    ) NOT FINAL;
    CREATE TYPE staff_type UNDER person_type
    Staff_number NUMBER (2,0)
    ) FINAL;
    CREATE TYPE student_type UNDER person_type (
    Student_number NUMBER (2,0),
    Enroled_in VARCHAR2(50),
    MEMBER FUNCTION getAge RETURN NUMBER
    )NOT FINAL;
    CREATE OR REPLACE TYPE BODY student_type AS
    MEMBER FUNCTION getAge RETURN NUMBER AS
    BEGIN
    RETURN Trunc(Months_Between(Sysdate, DOB)/12);
    END getAge;
    END;
    CREATE TYPE module_type AS OBJECT
    Module_number VARCHAR2(6),
    Module_name VARCHAR2(50),
    Credit NUMBER(2,0),
    Taught_in VARCHAR2(50)
    CREATE TYPE students_tab AS TABLE OF REF person_type;
    CREATE TYPE modules_tab AS TABLE OF REF module_type;
    CREATE TYPE course_type AS OBJECT
    Course_number NUMBER (2,0),
    Course_name VARCHAR2(50),
    Dept_name VARCHAR2(50),
    Taken_by Students_tab,
    Contains Modules_tab
    CREATE TABLE modules OF module_type(
    constraint pk_modules primary key (Module_number)
    CREATE TABLE courses OF course_type(
    constraint pk_courses primary key (Course_number)
    NESTED TABLE Taken_by STORE AS students_nt,
    NESTED TABLE Contains STORE AS modules_nt;

    By the way I am using oracle 9i and trying to insert into the nested table data from a subtype (i.e student is a subtype of person)

  • XY Scatter with multiple series: how to?

    Post Author: Dac
    CA Forum: Charts and Graphs
    Hi all,
    I want to represent multiple series of points in a XY chart - seems like a common thing to do - but i did not succeded in CRXI & Scatter chart.
    I've tried with these in the Data settings:
    Show value(s): put the 2 fields for X and Y axis
    Then selected 'On change of' and here was put the GroupBy field.
    The problem is that these settings summarize the X and Y values for all identical values from 'On change of' field. So i got just 1 point per seria...
    Then I saw somebody used an additional field for the 'On change of' - an unique field for every record (a formula RecordCount field) - so the grouping is done per record, then comes the CR warning that the data is not suitable for this type of chart, force and select Continue and the resutl is still not ok: it plots nothing or just 1 point. Though that user got the expected results.
    I've searched this site, googled - and found nothing that works.
    I still have hope this can be done - seems like a common thing for charting...
    Thank you

    Post Author: Dac
    CA Forum: Charts and Graphs
    thank you so much for the response and help!
    i've done the settings you said - it really makes sense what you saind in the message -  but still nothing is drawn on the chart.
    see the screen shot of all the settings and table data
    also there comes that warning CR message which i disregard and continue - but still does not work fine...
    any other suggestions? I still have hope for a solution

  • SAP PI7.31 : Mail with multiple attachments - how to process via UDF

    Hi
    wondering how I can approach this problem.   I have to read an Email with any number of attachments  - it can have between 1 and 4 or maybe more of different types (CSV,XLS,PDF,ZIP).  I need to read this email and extract the attachments to a folder.
    Just to let you know I have done this OK for an email that I know only has 2 attachments ! Works perfectly - just no good for ?n? attachments !
       Mail Sender has AF_Modules/MultipartHeaderBean to add payload Attributes
       The message is sent to 2 Receivers
       Each Receiver File adapter then uses AF_Modules/DynamicConfigurationBean and AF_Modules/PayloadSwapBean
    Problem is that when I do not know how many attachments there are.  So I will have to write a Java UDF mapping, perhaps using the classTransformationInput.
    My question is : To create a Java UDF what should be structure of a sent Email message Type look like so I can feed that into a UDF to check what payload attachments there are etc ?.

    As long as you use java mapping, you can have any dummy structures for your interfaces.
    But, if you prefer to use graphical mapping with UDF, then you should have some valid structures for your mail and file interfaces. e.g., mail pack XSD for mail interface as metioned by Indrajit Sarkar
    and again the same structure for the file interface as well so that you can have one to one mapping an then make use of UDF code from the article. Use payload swap bean in the receiver file channel to replace xml payload with Zipped attachments and then finally use script to unzip this zip file.
    Rgds,
    Praveen Gujjeti

  • Synchronizing Iterators for master view with multiple detail - how to ?

    New to JDeveloper (from Forms) and after an introduction a week or so back, one question I have not yet answered with the ADF framework is how to synchronize iterators. Maybe I missed something simple, but if I have master table A with FK relations from detail tables B and C expressed as view objects and view links in the Model tier, when I package these up into the Application Module / Data Controls it seems I have 2 iterators for table A - one for it and it's detail set B, and another for it and it's detail set C.
    So then, if I drag & drop one of the A data controls onto a page (say from the A-B link) as a read-only-table, my PPR actions from this table work on components derived from this same data control hierarchy - ie: on detail B. But to effect a change in the other detail relationship A-C, and components based on C, seems to mean moving this second iterator on A programmatically.
    How is this generally achieved using the ADF ? I've seen content about chaining master-detail-detail, but this is really master-detail(xN). View links only ever specify 2 tables. It seems I need to put some code in somewhere to move associated iterators when another iterator is moved.
    Also, is there an equivalent java code-point for the when-new-record-instance - ie: when an iterator moves to a different record, whether that be new or not. Not being able to find it thus far, I've put code in the executeQuery of the detail VO which fires when I need it, but there must be a better place.
    Thanks for the help.
    Edited by: litch on Jul 29, 2009 11:20 AM

    You can manipulate your AM Data Model so both details will be under the same master (as long as there are viewLinks from the master to both).
    Then you can drag them to the page and add PPR as described here:
    http://blogs.oracle.com/shay/2008/05/master_with_two_details_on_the.html

  • Drag Zones with multiple pictures - How to get them to play?

    I have struggled with this program for hours. In previous posting from 2005 people say there was a "bug" in the program so multiple pictures in drag zones would not play? Anyone know if this was fixed? Sure won't play for me and instruction manuals say up to 99 pictures can be dragged into them. If the theme has six drag zones, it plays those six pictures, but no more than that. It's driving me nuts!!!!!

    Hey observe... I am not sure, but are you trying to get the "DROP" zones in your themes to play more than one photo on your menu? (Not sure if Ive misread your question and subsequent replies, but in case I havent):
    If you want the drop zones to play "mini-slideshows" in your menu, you can do this in a couple of different ways. Firstly once youve added your slideshow to your iDVD theme you can then go to menu and press auto fill. This will put your slideshow into each of the drop zones. If you want them to play from different points of the slideshow just press on them and adjust the slider above them to the point where you want them to start. The other way you can do this is to create a mini-slideshow in iPhoto or FotoMagico or iMovie (without audio) for each drop zone and drop them in.

  • When a checkbox is selected with multiple items, how do I display those items at the bottom of a page so that follow-up on checked boxes can occur

    Hi,
    My name is Shawn and I work for Pfizer, an enterprise client of yours. We have thousands of LifeCycle licenses, but I don't know whom to contact to get support so I'm posting my question here.
    I am creating a PDF form that lets the user check a box when the want to select a web metric they need set up for their website. What I'd like to do is, once a user has checked this box (there are over 100), all the boxes they've checked out of the 100 or so metrics pop-up / show up / dynamically generate at the bottom page, and have additional checkboxes next to them for the development teams "eyes only" that they will have to in turn, when the form is emailed to them filled out, select TEST and VERIFY checkbox for each metric showing that they've tested and verified the metric was configured, and then a text field prompting them to say HOW they tested and verified / what method.
    How do I do this using LiveCycle?
    Thanks,
    Shawn

    What you're looking to do is created a dynamic form that changes on the click of a button.  This is done through script, and you have a couple of choices, there are several postings in these forms that provide guidance in this area (instancemanager is used for this dynamic capability).  Your second option is to use action builder and it will provide guidance for you as well.  Click on Tools > Action Builder.  Also depending on what version you have install location/EN/Samples/Forms/Purchase Order/Dynamic Interactive may help.

  • In a helpset with multiple chms, how do you make the master toc appear in all child chms?

    I'm using RoboHelp 11. The software product I'm documenting is modular so the help is also divided into many chms (requirement). One of the other requirements is that the TOC from the master project appear, no matter which which chm contains the link called by the software. I've done this with merged WebHelp (kudos to Peter Grainge), however I haven't been successful doing it for HTML help using RoboHelp. Has anyone attempted this successfully? Any tips would be appreciated.

    This requires you to make the following changes:
    In each of the projects, open the window being used to display the CHM. Click Advanced Properties and enter the file name of the master project's TOC in the "Table of Contents" field.
    Having compiled all the files, open up the Master project's .HHP file in Notepad. Look for the [MERGEDFILES] section. This should have a list of all the CHMs that make up the final deliverable. It has been some time since I've used CHMs, so I can't remember if you have to do this in all the projects. Try it in the master project first and you'll find out if you do.

  • I could not see how to continue after upgrade to firefox 4. This has never been a problem with ast upgrades. I am finding Firefox to be very user unfriendly for non-tech people.

    I am being told that my current version of firefox is no longer protected. When I tried to upgrade to firefox 4 some time ago, the menu bar(?) was gone--no bookmarks. I set my computer back to an earlier date to get my book marks back and have been afraid to attempt this upgrade again. Firefox also appears to have tried to do the upgrade automatically and says I have incompatible add-ons. I have never had problems with previous updates. I have read negative reviews of firefox 4 and am frankly afraid of it. I hate to leave firefox and am afraid of losing my book marks as well. I find the "Help" forums etc. here extremely difficult to navigate and they seem to be aimed at people who are more tech savy than many of us are.

    #Firefox 3.5.19 which you are using is no longer supported and is not being updated for any issues, including security problems.
    #The Menu Bar (File, Edit, View, History, Bookmarks, Tools, Help) was replaced in Firefox 4 by the "Firefox button" in the upper left corner
    #*You can turn the Menu Bar back on by doing one of the following in Firefox 4:
    #**click Firefox button, click Options, click Menu Bar to select it
    #**HOLD down the ALT key while pressing the keyboard letters VTM
    #**right-click on an empty space in the Navigation Toolbar, then click Menu Bar to select it.
    #Some information about Firefox 4 changes:
    #*https://www.mozilla.com/en-US/firefox/features/
    #*there is a link "watch the video" under '''''Improved Interface''''' on the above page
    #You can make Firefox 4 look more like prior versions: http://www.computertechtips.net/64/make-firefox-4-look-like-ff-3-6/
    Your bookmarks should be safe during the upgrade; they are in a separate place on your hard drive. You should keep them backed-up in case of any problems with your system. See:
    *https://support.mozilla.com/en-US/kb/Backing%20up%20your%20information#w_backing-up-your-profile
    *http://kb.mozillazine.org/Profile_backup
    *http://kb.mozillazine.org/Profile_folder_-_Firefox

  • How to continue after replicat abended?

    Hi,
    If my replicat abended fron user error - how do I proceed?
    With streams we sometimes fix the row (update/delete/insert) and did retry all error and sometimes we just expdp the data...

    Find out what the error is/was. Use a discard file, add in your own exception handling, look at the replicat report/ggsevt log. Fix and then restart the replicat.

  • Problem importing PSD (with multiple groups and layers) into After Effects. Help!

    I created a "comic strip" in photoshop (multiple rectangle shape layers, then various shapes within each box for each frame of the comic strip) that I want to import into AE. When I import it as a composition (to keep my layers), however, what appears is an simply a black image with white lines where the lines of the comic strip used to be. I checked the color modes, but they are both in RGB so I don't think that's the problem. Also, when I double click the cartoon strip composition, I can choose certain groups from the mini flow-chart at the top left and view those individual frames. However, I can't view the entire comic strip as a whole, which is necessary for my animation. Any help with this would be greatly appreciated, as I'm on a tight time constraint. Thanks!

    When I asked what version down to the last decimal, I meant it. After Effects version should start with 11, but we need the numbers after that too.
    And I understand that you want to pan between them, so just put all the different PSD's you import into the same comp and pan between them.

Maybe you are looking for

  • Routing with a multihomed Mac

    Hi, I have a Mac running Leopard 10.5.4 with two network cards in it, and I'm trying to get it to act as a router. The setup is very simple: A ---- M ---- B M is the Mac with two nics. The nic (en0) on computer M connected to computer A has an IP of

  • Purchase order in SmartForms

    hi, I am getting an error in ABAP program for smartform of Purchase order In Purchase order screen (ME21N) for any field I Pressed F1 and from technical details I got the TABLE name and field name, but when I put in Smartform report it gives me the b

  • NAS200 - Can See Public Drive but not private

    Recently, I purchased new Dell XPS and connected to my network.  I can "see" everything.  All computers are running Windows 7.  Home Premium on older ones and Professional on the new XPS. Now the real problem...  when I connect to NAS with new XPS, I

  • Get number of rows in ResultSet object

    Can anybody guide me on how to get the total number of rows in a result set object without iterating through all rows? Thanks.

  • BI for SAP PS(Project System)

    Hello, I will be working on BI in SAP PS related area soon. As i am SAP PS keyuser here i am understanding functional things better. But for BI what are the pre-requisites for PS. If anybody worked on BI in SAP PS related area please give some inputs