Save Exceptions Limitation

Hello Gurus,
I have a problem with the Save Exceptions. I am using database 11g.
When I am doing bulk insert I would like to insert the error records into a new table. But when I am inserting
the error records I am getting the error "error:- ORA-00984: column not allowed here
ORA-24381: error(s) in array DML".
I am putting my code below.
DECLARE
CURSOR C_FRT2STORE IS
SELECT ROWID,
STORE_CD,
MNR_CD,
'FRT',
DT,
TO_DATE('31-DEC-2049'),
FRT_FAC,
TRUNC(SYSDATE),
'ADMINUSR'
FROM FRT2STORE;
CURSOR C_FRT2STORE_EXC_TAB IS
SELECT 'Y'
FROM ALL_TABLES
WHERE TABLE_NAME = 'FRT2STORE_EXC';
TYPE STORE$MNR2CST_REC_TYPE IS RECORD
(C_STORE$MNR2CST_ROWID VARCHAR2(100),
C_STORE_CD STORE$MNR2CST.STORE_CD%TYPE,
C_MNR_CD STORE$MNR2CST.MNR_CD%TYPE,
C_CST_CD STORE$MNR2CST.CST_CD%TYPE,
C_BEG_DT STORE$MNR2CST.BEG_DT%TYPE,
C_END_DT STORE$MNR2CST.END_DT%TYPE,
C_FAC NUMBER(13,3), --STORE$MNR2CST.FAC%TYPE,       
C_AMT STORE$MNR2CST.AMT%TYPE,
C_CUBIC_AMT STORE$MNR2CST.CUBIC_AMT%TYPE,
C_LST_ACTN_DT STORE$MNR2CST.LST_ACTN_DT%TYPE,
C_EMP_CD STORE$MNR2CST.EMP_CD%TYPE
TYPE STORE$MNR2CST_TYPE IS TABLE OF STORE$MNR2CST_REC_TYPE
INDEX BY PLS_INTEGER;
STORE$MNR2CST_COL STORE$MNR2CST_TYPE;
V_TOT_REC PLS_INTEGER := 0;
V_FRT2STORE_EXC_TAB CHAR(1);
V_TOT_REC_IN_STORE$MNR2CST PLS_INTEGER;
V_ERR_REC PLS_INTEGER;
BULK_ERRORS EXCEPTION;
PRAGMA EXCEPTION_INIT (BULK_ERRORS, -24381);
BEGIN
--GETTING DATA FROM FRT2STORE TABLE AND INSERTING INTO THE STORE$MNR2CST TABLE
SELECT COUNT(1)
INTO V_TOT_REC_IN_STORE$MNR2CST
FROM STORE$MNR2CST ;
IF V_TOT_REC_IN_STORE$MNR2CST = 0 THEN
OPEN C_FRT2STORE;
LOOP
FETCH C_FRT2STORE BULK COLLECT INTO STORE$MNR2CST_COL LIMIT 1000;
EXIT WHEN STORE$MNR2CST_COL.COUNT = 0;
V_TOT_REC := STORE$MNR2CST_COL.COUNT;
IF V_TOT_REC > 0 THEN
BEGIN
FORALL I IN STORE$MNR2CST_COL.FIRST..STORE$MNR2CST_COL.LAST SAVE EXCEPTIONS
INSERT INTO STORE$MNR2CST
(STORE_CD,
MNR_CD,
CST_CD,
BEG_DT,
END_DT,
FAC,
AMT,
CUBIC_AMT,
LST_ACTN_DT,
EMP_CD
VALUES
(STORE$MNR2CST_COL(I).C_STORE_CD,
STORE$MNR2CST_COL(I).C_MNR_CD,
STORE$MNR2CST_COL(I).C_CST_CD,
STORE$MNR2CST_COL(I).C_BEG_DT,
STORE$MNR2CST_COL(I).C_END_DT,
STORE$MNR2CST_COL(I).C_FAC,
STORE$MNR2CST_COL(I).C_AMT,
STORE$MNR2CST_COL(I).C_CUBIC_AMT,
STORE$MNR2CST_COL(I).C_LST_ACTN_DT,
STORE$MNR2CST_COL(I).C_EMP_CD
COMMIT;
EXCEPTION WHEN BULK_ERRORS THEN
OPEN C_FRT2STORE_EXC_TAB;
FETCH C_FRT2STORE_EXC_TAB INTO V_FRT2STORE_EXC_TAB;
IF C_FRT2STORE_EXC_TAB%NOTFOUND THEN
EXECUTE IMMEDIATE ('CREATE TABLE FRT2STORE_EXC AS SELECT * FROM FRT2STORE WHERE 1 = 2');
END IF;
CLOSE C_FRT2STORE_EXC_TAB;
FOR J IN 1..SQL%BULK_EXCEPTIONS.COUNT
LOOP
V_ERR_REC := SQL%BULK_EXCEPTIONS(J).ERROR_INDEX;
EXECUTE IMMEDIATE 'INSERT INTO FRT2STORE_EXC (STORE_CD,MNR_CD,FRT_FAC,DT) VALUES ('
||STORE$MNR2CST_COL(V_ERR_REC).C_STORE_CD||','
||STORE$MNR2CST_COL(V_ERR_REC).C_MNR_CD||','
||STORE$MNR2CST_COL(V_ERR_REC).C_FAC||','
||STORE$MNR2CST_COL(V_ERR_REC).C_BEG_DT||')';
END LOOP;
COMMIT;
END;
STORE$MNR2CST_COL.DELETE;
END IF;
END LOOP;
CLOSE C_FRT2STORE;
END IF;
COMMIT;
EXCEPTION WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('error:- '||SQLERRM);
END ;
Could any one tell me how to achive this requirment.
Thanks,
Sun

1. Please format your code using the code tags.
2. You should never need to code create tables like this "EXECUTE IMMEDIATE ('CREATE TABLE FRT2STORE....". This is often seen when creating temporary tables in non-Oracle database but is a misunderstanding in how to do things in Oracle. You should create them outside of your plsql as permanent objects.
3. In your example, you should not need dynamic sql like this "EXECUTE IMMEDIATE 'INSERT INTO FRT2STORE_EXC...."
4. In 10gR2 / 11g, DML Error Logging might be a better solution
http://www.oracle.com/technology/oramag/oracle/06-mar/o26performance.html

Similar Messages

  • How to handle multiple save exceptions (Bulk Collect)

    Hi
    How to handle Multiple Save exceptions? Is it possible to rollback to first deletion(of child table) took place in the procedure.
    There are 3 tables
    txn_header_interface(Grand Parent)
    orders(parent)
    order_items (Child)
    One transaction can have one or multiple orders in it.
    and one orders can have one or multiple order_items in it.
    We need to delete the data from child table first then its parent and then from the grand parent table.if some error occurs anywhere I need to rollback to child record deletion. Since there is flag in child table which tells us when to delete data from database.
    Is it possible to give name to Save exceptions?
    e.g.
    FORALL i IN ABC.FIRST..ABC.LAST SAVE EXCEPTIONS A
    FORALL i IN abc.FIRST..ABC.LAST SAVE EXCEPTIONS B
    if some error occurs then
    ROLLBACK A; OR ROLLBACK B;
    Please find the procedure attached
    How to handle the errors with Save exception and rollback upto child table deletion.
    CREATE OR REPLACE
    PROCEDURE DELETE_CONFIRMED_DATA IS
    TYPE TXN_HDR_INFC_ID IS TABLE OF TXN_HEADER_INTERFACE.ID%TYPE;
    TXN_HDR_INFC_ID_ARRAY TXN_HDR_INFC_ID;
    ERROR_COUNT NUMBER;
    BULK_ERRORS EXCEPTION;
    PRAGMA exception_init(bulk_errors, -24381);
    BEGIN
    SELECT THI.ID BULK COLLECT
    INTO TXN_HDR_INFC_ID_ARRAY
    FROM TXN_HEADER_INTERFACE THI,ORDERS OS,ORDER_ITEMS OI
    WHERE THI.ID = OS.TXN_HDR_INFC_ID
    AND OS.ID = OI.ORDERS_ID
    AND OI.POSTING_ITEM_ID = VPI.ID
    OI.DW_STATUS_FLAG =4 --data is moved to Datawarehouse
    MINUS
    (SELECT THI.ID FROM TXN_HEADER_INTERFACE THI,ORDERS OS,ORDER_ITEMS OI
    WHERE THI.ID = OS.TXN_HDR_INFC_ID
    AND OS.ID = OI.ORDERS_ID
    OI.DW_STATUS_FLAG !=4);
    IF SQL%NOTFOUND
    THEN
    EXIT;
    END IF;
    FORALL i IN TXN_HDR_INFC_ID_ARRAY.FIRST..TXN_HDR_INFC_ID_ARRAY.LAST SAVE
    EXCEPTIONS
    DELETE FROM ORDER_ITEMS OI
    WHERE OI.ID IN (SELECT OI.ID FROM ORDER_ITEMS OI,ORDERS
    OS,TXN_HEADER_INTERFACE THI
    WHERE OS.ID = OI.ORDERS_ID
    AND OS.TXN_HDR_INFC_ID = THI.ID
    AND THI.ID = TXN_HDR_INFC_ID_ARRAY(i));
    FORALL i IN TXN_HDR_INFC_ID_ARRAY.FIRST..TXN_HDR_INFC_ID_ARRAY.LAST SAVE
    EXCEPTIONS
    DELETE FROM ORDERS OS
    WHERE OS.ID IN (SELECT OS.ID FROM ORDERS OS,TXN_HEADER_INTERFACE THI
    WHERE OS.TXN_HDR_INFC_ID = THI.ID
    AND THI.ID = TXN_HDR_INFC_ID_ARRAY(i));
    FORALL i IN TXN_HDR_INFC_ID_ARRAY.FIRST..TXN_HDR_INFC_ID_ARRAY.LAST SAVE
    EXCEPTIONS
    DELETE FROM TXN_HEADER_INTERFACE THI
    WHERE THI.ID = TXN_HDR_INFC_ID_ARRAY(i);
    COMMIT;
    DBMS_OUTPUT.PUT_LINE(TO_CHAR(SYSDATE, 'DD-MON-YY HH:MIPM')||':
    DELETE_CONFIRMED_DATA: INFO:DELETION SUCCESSFUL');
    EXCEPTION
    WHEN OTHERS THEN
    ERROR_COUNT := SQL%BULK_EXCEPTIONS.COUNT;
    DBMS_OUTPUT.PUT_LINE(TO_CHAR(SYSDATE, 'DD-MON-YY HH:MIPM')||':
    DELETE_CONFIRMED_DATA: ERROR:Number of errors is ' ||ERROR_COUNT);
    FOR indx IN 1..ERROR_COUNT LOOP
    DBMS_OUTPUT.PUT_LINE('Error ' || indx || 'occurred during
    '||'iteration'||SQL%BULK_EXCEPTIONS(indx).ERROR_INDEX);
    DBMS_OUTPUT.PUT_LINE('Error is '
    ||SQLERRM(-SQL%BULK_EXCEPTIONS(indx).ERROR_CODE));
    END LOOP;
    END DELETE_CONFIRMED_DATA;
    Any suggestion would be of great help.
    Thanks in advance
    Anu

    If you have one or two places in your code that need multiple exceptions, just do it with multiple catch statements. Unless you are trying to write the most compact Programming 101 homework program, inventing tricks to remove two lines of code is not good use of your time.
    If you have multiple catches all over your code it could be a code smell. You may have too much stuff happening inside one try statement. It becomes hard to know what method call throws one of those exceptions, and you end up handling an exception from some else piece of code than what you intended. E.g. you mention NumberFormatException -- only process one user input inside that try/catch so it is easy to see what error message is given if that particular input is gunk. The next step of processing goes inside its own try/catch.
    In my case, the ArrayIndexOutOfBoundsException and
    NumberFormatException should be handled by the same way.Why?
    I don't think I have ever seen an ArrayIndexOutOfBoundsException that didn't indicate a bug in the code. Instead of an AIOOBE perhaps there should be an if statement somewhere that prevents it, or the algorithm logic should prevent it automatically.

  • SAVE EXCEPTION CLAUSE

    I'm trying to use the SAVE EXCEPTION clause and load all the records that error into an error table. example of my code is below. This code does not compile, it does not like the way I refrence a column in the collection ie.
    recs.sku(SQL%BULK_EXCEPTIONS(i).ERROR_INDEX)
    is there a better way to do this?
    this is the code:
    TYPE table_object IS TABLE OF tran_data_stage%ROWTYPE;
    recs TABLE_OBJECT;
    l_errors NUMBER(9);
    CURSOR c_tdh_source IS
    SELECT
    sku,
    store,
    wh,
    vdate,
    NULL
    FROM tran_data_history
    WHERE vdate between sysdate -6
    and sysdate;
    BEGIN
    OPEN c_tdh_source;
    LOOP
    BEGIN
    FETCH c_tdh_source BULK COLLECT INTO recs LIMIT 100;
    FORALL i IN recs.FIRST..recs.LAST SAVE EXCEPTIONS
    INSERT INTO tran_data_stage VALUES recs(i);
    EXIT WHEN c_tdh_source%NOTFOUND;
    EXCEPTION
    WHEN OTHERS THEN
    l_errors := SQL%BULK_EXCEPTIONS.COUNT;
    dbms_output.put_line('Number of errors is ' || l_errors);
    FOR i IN 1..l_errors LOOP
    dbms_output.put_line('Error ' || i || ' occurred during '||
    'iteration ' || SQL%BULK_EXCEPTIONS(i).ERROR_INDEX);
    dbms_output.put_line('Oracle error is ' ||
    SQLERRM(-SQL%BULK_EXCEPTIONS(i).ERROR_CODE));
    INSERT INTO tran_data_stage_errors VALUES
    recs.sku(SQL%BULK_EXCEPTIONS(i).ERROR_INDEX), --here is the error
    5,
    sysdate
    END LOOP;
    END;
    END LOOP;
    COMMIT;
    CLOSE c_tdh_source;
    EXCEPTION
    WHEN OTHERS THEN
    dbms_output.put_line('others error occured' || SQLERRM);
    END;

    Shouldn't that berecs(SQL%BULK_EXCEPTIONS(i).ERROR_INDEX).sku

  • SAVE EXCEPTIONS when fetching from cursors by BULK COLLECT possible?

    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
    Hello,
    I'm using an Cursor's FETCH by BULK COLLECT INTO mydata...
    Is it possible to SAVE EXCEPTIONS like with FORALL? Or is there any other possibility to handle exceptions during bulk-fetches?
    Regards,
    Martin

    The cursor's SELECT-statement uses TO_DATE(juldat,'J')-function (for converting an julian date value to DATE), but some rows contain an invalid juldat-value (leading to ORA-01854).
    I want to handle this "rows' exceptions" like in FORALL.
    But it could also be any other (non-Oracle/self-made) function within "any" BULK instruction raising (un)wanted exceptions... how can I handle these ones?
    Martin

  • Save Exceptions Memory Issue

    I'm currently using a bulk collect (limit = 100) and a forall insert to load roughly 6.2 million records into a table. If I leave the "Save Exceptions" clause out of the procedure, all 6.2 million records are loaded without an error. THe amount of memory used never exceeds 40MB. If I include the "Save Exceptions" clause and put in the code to record any errors encountered, the memory jumps to over 200MB and the procedure is exceedingly slow. Also, I put a debugging statement after each forall insert to validate that the SQL%BULK_EXCEPTIONS.COUNT = 0 for each iteration. The procedure still completes with no errors, but the memory utilized is still way too high.
    Has anyone run into this before? Is there an environmental setting that needs to be set to use "Save Exceptions" with many rows of data?
    We are currently running 9.2.0.3.0.
    Thanks,
    Scott

    Hello.
    Thank you for your answers. Let me react:
    re 1. - this is the last possible solution which I don't want to take unless it is clear that the upgrade will fix the problem
    re 2. APPEND - just trying to improve the insert, I am not sure if this bit works, however it does not affect the memory problem
    re 3. in accordance with my understanding the LIMIT clause will not help. The amount of data we process in one step is not huge - not more then 10 000 records.
    re 4. we are already doing it, I was just interested whether someone has already seen this problem or not.
    So far I have not found any solutions...

  • FORALL ... SAVE EXCEPTIONS

    Hi folks,
    I want to transfer BULK data from exception_test1 to exception_test2 with FORALL ... SAVE EXCEPTIONS
    procedure execute successfull but no data transfer & no exception raise..
    create or replace
    PROCEDURE forall_exception
    AS
    TYPE t_tab IS TABLE OF exception_test1%ROWTYPE;
    l_tab t_tab := t_tab();
    l_error_count NUMBER;
    ex_dml_errors EXCEPTION;
    PRAGMA EXCEPTION_INIT(ex_dml_errors, -24381); --24381
    -- Perform a bulk operation.
    BEGIN
    FORALL i IN l_tab.first .. l_tab.last SAVE EXCEPTIONS
    INSERT INTO exception_test2
    VALUES l_tab(i);
    EXCEPTION
    WHEN ex_dml_errors THEN
    l_error_count := SQL%BULK_EXCEPTIONS.count;
    DBMS_OUTPUT.put_line('Number of failures: ' || l_error_count);
    FOR i IN 1 .. l_error_count LOOP
    DBMS_OUTPUT.put_line('Error: ' || i ||
    ' Array Index: ' || SQL%BULK_EXCEPTIONS(i).error_index ||
    ' Message: ' || SQLERRM(-SQL%BULK_EXCEPTIONS(i).ERROR_CODE));
    END LOOP;
    -- END;
    END;

    Hi,
    You have declared the collection. To get the data into the collection, you need to fetch the data into it and then use it later.
    Modify your code to something like:
    create or replace PROCEDURE forall_exception (in_key_val in number)
    AS
    TYPE t_tab IS TABLE OF exception_test1%ROWTYPE;
    l_tab t_tab := t_tab();
    l_error_count NUMBER;
    ex_dml_errors EXCEPTION;
    PRAGMA EXCEPTION_INIT(ex_dml_errors, -24381); --24381
    -- Perform a bulk operation.
    BEGIN
    SELECT * BULK COLLECT INTO l_tab FROM exception_test1 WHERE key_val = in_key_val;
    FORALL i IN l_tab.first .. l_tab.last SAVE EXCEPTIONS
    INSERT INTO exception_test2 VALUES l_tab(i);
    EXCEPTION
    WHEN ex_dml_errors THEN
    l_error_count := SQL%BULK_EXCEPTIONS.count;
    DBMS_OUTPUT.put_line('Number of failures: ' || l_error_count);
    FOR i IN 1 .. l_error_count LOOP
         DBMS_OUTPUT.put_line('Error: ' || i ||
              ' Array Index: ' || SQL%BULK_EXCEPTIONS(i).error_index ||
              ' Message: ' || SQLERRM(-SQL%BULK_EXCEPTIONS(i).ERROR_CODE));
    END LOOP;
    END;
    /With this, you will have the record fetched into collection l_tab. If any exception occurs, those exceptions will be saved and printed later.

  • Oracle 9i Problem when using multicolumn bulk update with "save exceptions"

    I'm running into a problem with Oracle 9i when running a multicolumn update with "save exceptions". The problem occurs when updating 4 or more fileds. (The data being updated are 40 character text strings)
    I'm updating 1000 records at a time, in bulk.
    The problem goes away when I don't use "save exception" (i.e. catch the exception the normal "pre-Oracle 9i" way) or when I use "save exception" with 3 or fewer fields.
    (I don't get any exceptions when running without the "save exception")
    Thanks

    The problem is an ORA-14403 error detected during bulk updates only when "save exception" is used with more than 3 fields being updated.
    Remove the "save exception" I can update any number of fields.
    or
    Reduce the number of fields being updated to 3 or less and use save exceptions and the 14403 error goes away.
    (I'd like to use "save exception" without having to break the "update" into two separate 3 field updates.)
    Thanks,
    Len

  • Save Exception

    I have used save exception in a FORALL statement and the common error I return is ORA-20000.
    However I get no associated error code. Is this becvause the error is user defined in the db?
    The exception handler is as follows is as follows:
    WHEN bulk_errors THEN
    FOR j IN 1 .. SQL%BULK_EXCEPTIONS.COUNT
    LOOP
    dbms_output.put_line
    ('Error ' || j || ' at iteration ' ||SQL%BULK_EXCEPTIONS(j).ERROR_INDEX || ' desc ' ||pono_tab(SQL%BULK_EXCEPTIONS(j).ERROR_INDEX)||'/'||poli_tab(SQL%BULK_EXCEPTIONS(j).ERROR_INDEX));
    dbms_output.put_line(' OR Err ' ||SQLERRM(-1 * SQL%BULK_EXCEPTIONS(j).ERROR_CODE));
    END LOOP;

    I suppose that's what I should be trying to track down...where the error is actually occurring!!
    Thanks for your interest.
    I will try and run the update without the bulk bind and see if the error stack is more informative.
    PS.
    The application is riddled with inconsistancies in how errors are handled so I am not holding out much hope!!

  • T61P XP/SP3 - Power Manager Problems, Can't save schemes, limited schemes available

    Hi All - When I got this -rockin'- laptop originally I could set my own power schemes without problem.  Now it won't save my new powerschemes.  I try to create one, finish the last step, and then the power scheme isn't in the dropdown.  I read somewhere on the Web that this may be related to SP3. 
    Also, the only Power Schemes I have access to are Video Playback and Maximum Performance.  I have tried uninstalling Power Manager and the associated DLL and then reinstalling, but that didn't help.  Also, I see no reference to this problem in troubleshooting.  Thanks in advance.  This is getting really annoying as I like to use as little power as possible since I use teh computer on battery power quite often.
    Thanks!  g- 
    Solved!
    Go to Solution.

    First, don't mark an item solved if it's not solved. Second, learn to search to see if others have had this problem. instead of repeating a post that's been beaten to death. Hint: Lots of us have had the problem .
    If you had searched you would have found this link: http://chris.brandlehner.at/Brandlehner/cab_blog.nsf/d6plinks/CBRR-6YWBNV where you will see a possible solution. If it works, you can mark the entry "solved". Good luck.
    T520 4239-CTO
    T61/p 6459-CTO (Gone but not forgotten)
    A31/p XP Pro 1 gig memory
    A30/p XP Pro 1 gig memory
    TP600 Win 2K 288 mb memory
    701C Win 98 Don't ask

  • Save as limitations

    When I save a new Numbers file I am unable to save it exactly where I want to. I have to save it into general documents folder and then move it afterward. Anyone else notice this?

    I just bought an iMac today, and am having a similar problem as the OP of this thread. I've got several Microsoft Excel files on a jump drive that I need to be able to use and maintain on the jump drive. It seems that perhaps my iMac isn't fully recognizing my flash drive?
    I get the white icon in the upper right corner of the screen, and through that I can browse through all the files on the drive and open the one I want, but that is the only way I can get to the files. Then, when I try to save the file back onto the flash drive directly, I cannot do so.
    I tried doing the expanded save options as the two of you pointed out, but under the "Devices" heading, my iMac is only displaying my Mac HD and iDisk (which I don't have anyway). Based upon the screen shots you both provided, I'm guessing that the flash drive should be shown under the "Devices" heading, but it is not.
    Any possible help would be greatly appreciated by this new Mac owner.

  • Bulk collect exception save

    DROP TABLE TEST1;DROP TABLE TEST2;
    CREATE TABLE TEST1(TNO NUMBER(10), TNAME VARCHAR2(5));
    CREATE TABLE TEST2(TNO NUMBER(10), TNAME VARCHAR2(3), ERR_MSG VARCHAR2(1000));
    INSERT INTO TEST1 VALUES(1,'CAT');
    INSERT INTO TEST1 VALUES(2,'CAT');
    INSERT INTO TEST1 VALUES(3,'CAT1');
    INSERT INTO TEST1 VALUES(4,'CAT1');
    INSERT INTO TEST1 VALUES(5,'CAT1');
    INSERT INTO TEST1 VALUES(6,'CAT');
    INSERT INTO TEST1 VALUES(7,'CAT');
    SELECT * FROM TEST1;
    SELECT * FROM TEST2;
    COMMIT;
    anonymous block:
    DECLARE
       TYPE NumList IS TABLE OF TEST1%ROWTYPE;
       num_tab NumList := NumList();
       CURSOR C1 IS SELECT * FROM TEST1;
       errors  NUMBER;
       dml_errors EXCEPTION;
       PRAGMA exception_init(dml_errors, -24381);
    BEGIN
    FOR I IN C1 LOOP
    num_tab.EXTEND;
    num_tab (num_tab.LAST).TNO := I.TNO;
    num_tab (num_tab.LAST).TNAME := I.TNAME;
    END LOOP;
       FORALL i IN num_tab.FIRST..num_tab.LAST SAVE EXCEPTIONS
          INSERT INTO TEST2(TNO,TNAME) VALUES (num_tab(i).TNO,num_tab(i).TNAME);
    EXCEPTION
      WHEN dml_errors THEN
          errors := SQL%BULK_EXCEPTIONS.COUNT;
       dbms_output.put_line('Number of errors is ' || 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('Oracle error is ' ||
             SQLERRM(-SQL%BULK_EXCEPTIONS(i).ERROR_CODE));
       END LOOP;
    END;
    my need is i want to save the exception record in the same table (test2) with error message in ERR_MSG column
    result is
    SELECT * FROM TEST2;
    TNO                    TNAME ERR_MSG                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
    1                      CAT                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
    2                      CAT                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
    6                      CAT                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
    7                      CAT                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
    4 rows selected
    required result is
    TNO                    TNAME ERR_MSG                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
    1                      CAT                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
    2                      CAT                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
    3                      E     Oracle error is ORA-12899: value too large for column  (actual: , maximum: )
    4                      E     Oracle error is ORA-12899: value too large for column  (actual: , maximum: )
    5                      E     Oracle error is ORA-12899: value too large for column  (actual: , maximum: )
    6                      CAT                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
    7                      CAT                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
    7 rows selected

    How about the following (in the exception block)?
    G
    DECLARE
       TYPE NumList IS TABLE OF TEST1%ROWTYPE;
       num_tab NumList := NumList();
       CURSOR C1 IS SELECT * FROM TEST1;
       errors  NUMBER;
       dml_errors EXCEPTION;
       PRAGMA exception_init(dml_errors, -24381);
    BEGIN
    FOR I IN C1 LOOP
    num_tab.EXTEND;
    num_tab (num_tab.LAST).TNO := I.TNO;
    num_tab (num_tab.LAST).TNAME := I.TNAME;
    END LOOP;
       FORALL i IN num_tab.FIRST..num_tab.LAST SAVE EXCEPTIONS
          INSERT INTO TEST2(TNO,TNAME) VALUES (num_tab(i).TNO,num_tab(i).TNAME);
    EXCEPTION
      WHEN dml_errors THEN
         DECLARE
            TYPE NumList2 IS TABLE OF TEST2%ROWTYPE;
            err_tab NumList2 := NumList2();
         BEGIN
            errors := SQL%BULK_EXCEPTIONS.COUNT;
            FOR i IN 1..errors LOOP
               err_tab.EXTEND;
               err_tab(err_tab.LAST).TNO     := num_tab(SQL%BULK_EXCEPTIONS(i).ERROR_INDEX).TNO;
               err_tab(err_tab.LAST).TNAME   := 'E';
               err_tab(err_tab.LAST).ERR_MSG := SQLERRM(-SQL%BULK_EXCEPTIONS(i).ERROR_CODE);
            END LOOP;
            FORALL j IN err_tab.FIRST..err_tab.LAST
               INSERT INTO TEST2 VALUES err_tab(j);
          END; 
    END;
     

  • Forall exception rollback

    Hi Guys,
    I have a forall statement that I want to continue processing if it hits an exception, and rollback anything it fails on. I have limits set so I am only lifting 300 records at a time, but if only one record fails in the forall, then i want the other 299 to process and commit, and only rollback that one failure..is it possible? This is using oracle 10g.
    Example snippet below, the "dots" are just were I have removed unneeded code for this example. I want to know if I can add a rollback in the EXCEPTION that will rollback the forall failure for the one saved exception, and the "commit" will commit the remaining 299 that were success?
    BEGIN
    LOOP
    FETCH cursor1
    BULK COLLECT INTO table1 LIMIT 300;
    IF table1.COUNT > 0
    THEN
    BEGIN
    FORALL i IN 1 .. table1.COUNT SAVE EXCEPTIONS
    END IF;
    EXIT WHENtable1.COUNT = 0;
    table1.DELETE;
    END LOOP;
    CLOSE cursor1;
    COMMIT;
    EXCEPTION
    WHEN OTHERS
    THEN
    ROLLBACK;
    END;
    Edited by: fixxxer on 13-Oct-2011 01:36

    You can not do INSERT and DELETE using same FORALL statelemt. For that you have to create seperate copy of Collection.
    If you want to ROLLBACK everything thnen omit the SAVE EXCEPTION statement in FORALL.
    You can gothrough below FORALL restriction...
    Restrictions
    The following restrictions apply to the FORALL statement:
    •You cannot loop through the elements of an associative array that has a string type for the key.
    •Within a FORALL loop, you cannot refer to the same collection in both the SET clause and the WHERE clause of an UPDATE statement. You might need to make a second copy of the collection and refer to the new name in the WHERE clause.
    •You can use the FORALL statement only in server-side programs, not in client-side programs.
    •The INSERT, UPDATE, or DELETE statement must reference at least one collection. For example, a FORALL statement that inserts a set of constant values in a loop raises an exception.
    •When you specify an explicit range, all collection elements in that range must exist. If an element is missing or was deleted, you get an error.
    •When you use the INDICES OF or VALUES OF clauses, all the collections referenced in the DML statement must have subscripts matching the values of the index variable. Make sure that any DELETE, EXTEND, and so on operations are applied to all the collections so that they have the same set of subscripts. If any of the collections is missing a referenced element, you get an error. If you use the SAVE EXCEPTIONS clause, this error is treated like any other error and does not stop the FORALL statement.
    •You cannot refer to individual record fields within DML statements called by a FORALL statement. Instead, you can specify the entire record with the SET ROW clause in an UPDATE statement, or the VALUES clause in an INSERT statement.
    •Collection subscripts must be just the index variable rather than an expression, such as i rather than i+1.
    •The cursor attribute %BULK_ROWCOUNT cannot be assigned to other collections, or be passed as a parameter to subprograms.

  • Error Message in Bulk Exception.

    Hi
    When i use a normal Exception, the SQLERRM gives me the complete error along with the column name.
    Ex :
    ORA-01400: cannot insert NULL into ("BENCHMARK"."T6"."X")
    But
    When i Use Bulk_Exception, SQLERRM does not give me the complete error along with column name.
    Ex:
    ORA-01400: cannot insert NULL into ()
    Is it that Bulk_exception error messages are less informative. These error messages, does not help me in finding out which column is violation the NOT NULL constraint and hence they actually make no sense.
    Is there any way, through which i can get the complete error message as i get in the normal exception.
    I am using 9i version.
    Regards
    Nikhil

    I couldn't find exact solution to your problem, but one idea that came to mind, is resubmit statement with problematic rows (without using bulk processing) and save error messages.
    SQL> declare
      2    bulk_errors exception;
      3    pragma exception_init ( bulk_errors, -24381 );
      4   
      5    j number;   
      6   
      7    type numbers is table of number;
      8    ids numbers;
      9  begin
    10    select case when mod(abs(dbms_random.random),3)=0 then null else 1 end id bulk collect into ids
    11      from dual
    12    connect by level < 10;
    13   
    14    forall i in ids.first .. ids.last save exceptions
    15      insert into test01 values ( ids(i) );
    16    exception when bulk_errors then
    17       for i in 1..sql%bulk_exceptions.count loop
    18         j := sql%bulk_exceptions(i).error_index;
    19         begin
    20            insert into test01 values ( ids(j) );
    21         exception when others then
    22            dbms_output.put_line( 'Row #'||j||'. '||substr(sqlerrm,1,instr(sqlerrm,chr(10))-1) );
    -- substr to get only the first line
    23         end;
    24       end loop;
    25  end;
    26  /
    Row #1. ORA-01400: cannot insert NULL into ("SCOTT"."TEST01"."ID")
    Row #3. ORA-01400: cannot insert NULL into ("SCOTT"."TEST01"."ID")
    Row #6. ORA-01400: cannot insert NULL into ("SCOTT"."TEST01"."ID")
    Row #7. ORA-01400: cannot insert NULL into ("SCOTT"."TEST01"."ID")
    Row #8. ORA-01400: cannot insert NULL into ("SCOTT"."TEST01"."ID")
    Row #9. ORA-01400: cannot insert NULL into ("SCOTT"."TEST01"."ID")

  • One-click 'Save as jpeg' shortcut script please! - saved in the same folder

    Hi, I've been re-directed here because I was told a script could solve my problems - but I have no scripting experience/knowledge/ability! Below is my original problem and post. I got as close as 2 button presses, but I'm after that sweet, sweet single-button, double-my-productivity shortcut! Thanks!
    http://forums.adobe.com/thread/1106992
    I use 'Save as .jpeg' ALL the time (Photoshop CS6, Mac ML), and it really feels like I should just be able to press one button (a shortcut) and the name/quality dialogs don't appear and it just saves a .jpeg into the folder that my original .PSD/file is in.
    So basically:
    - Press one button to save my open .PSD/file as a .jpeg
    - Automatically save it in the same folder as my .PSD
    - Save it as '10' quality in the jpeg settings
    - No dialog boxes, as soon as I press the button, it saves it - if there's already a .jpeg of the same name, it creates a '-1','-2' etc.
    I've tried using 'Actions', but it seems to save it wherever my original Action folder was - it doesn't change to whatever the current folder the .PSD is in...
    Thanks!
    Adam

    File -> Scripts -> Script Events Manager
    Click Enable Events at the top
    Select Save Document from Photoshop Event  drop down
    Select Save Extra JPEG from Script drop down
    Click Add
    Click Done
    EVERY document you save, except JPEG files, will save a jpg file. Saving will be slower.
    You will need to modify line 62 of the Save Extra JPEG.jsx file located here: <YOUR_PHOTOSHOP_INSTALL_LOCATION>\Presets\Scripts\Event Scripts Only
    In order to boost your quality to '10'. Here is the line in question
    jpegOptions.quality = 2; // really low
    Change it to
    jpegOptions.quality = 10; // really high
    You will need to modify the script to get this problem solved as well: it saves it - if there's already a .jpeg of the same name, it creates a '-1','-2' etc.
    You can steal code out of Image Processor that finds a file name that is unique for the folder so you don't get overwrites.
    Are you sure you want that? If you do lots of saves you are going to fill up your disk fast.

  • Invalidate() throws null pointer exception

    Hi experts,
    Any idea why calling invalidate will throw a null pointer exception.
    if (detailNode != null)
         detailNode.invalidate();
    This is the stack trace:
    java.lang.NullPointerException
         at com.sap.tc.webdynpro.progmodel.controller.MessageManager.setAttributeValidbyContext(MessageManager.java:656)
         at com.sap.tc.webdynpro.progmodel.context.NodeElement.clearPendingInput(NodeElement.java:297)
         at com.sap.tc.webdynpro.progmodel.context.NodeElement.exit(NodeElement.java:132)
         at com.sap.tc.webdynpro.progmodel.context.Node$ElementList.exit(Node.java:1859)
         at com.sap.tc.webdynpro.progmodel.context.Node.clearElements(Node.java:1560)
         at com.sap.tc.webdynpro.progmodel.context.Node.onNodeInvalidating(Node.java:1447)
         at com.sap.tc.webdynpro.progmodel.context.Node.fireNodeInvalidating(Node.java:1410)
         at com.sap.tc.webdynpro.progmodel.context.Node.clearElements(Node.java:1556)
         at com.sap.tc.webdynpro.progmodel.context.Node.onNodeInvalidating(Node.java:1447)
         at com.sap.tc.webdynpro.progmodel.context.Node.fireNodeInvalidating(Node.java:1410)
         at com.sap.tc.webdynpro.progmodel.context.Node.clearElements(Node.java:1556)
         at com.sap.tc.webdynpro.progmodel.context.Node.invalidate(Node.java:583)
         at com.sap.tc.webdynpro.progmodel.context.Node.invalidate(Node.java:580)
         at com.diagonal.mmm.component.MenuDetailsController.save(MenuDetailsController.java:281)
         at com.diagonal.mmm.component.wdp.InternalMenuDetailsController.save(InternalMenuDetailsController.java:1250)
         at com.diagonal.mmm.view.MenuDetailsView.onActionSave(MenuDetailsView.java:965)
         at com.diagonal.mmm.view.wdp.InternalMenuDetailsView.wdInvokeEventHandler(InternalMenuDetailsView.java:999)
         at com.sap.tc.webdynpro.progmodel.generation.DelegatingView.invokeEventHandler(DelegatingView.java:87)
         at com.sap.tc.webdynpro.progmodel.controller.Action.fire(Action.java:67)
         at com.sap.tc.webdynpro.clientserver.window.WindowPhaseModel.doHandleActionEvent(WindowPhaseModel.java:420)
         at com.sap.tc.webdynpro.clientserver.window.WindowPhaseModel.processRequest(WindowPhaseModel.java:132)
         at com.sap.tc.webdynpro.clientserver.window.WebDynproWindow.processRequest(WebDynproWindow.java:335)
         at com.sap.tc.webdynpro.clientserver.cal.AbstractClient.executeTasks(AbstractClient.java:143)
         at com.sap.tc.webdynpro.clientserver.session.ApplicationSession.doProcessing(ApplicationSession.java:313)
         at com.sap.tc.webdynpro.clientserver.session.ClientSession.doApplicationProcessingStandalone(ClientSession.java:713)
         at com.sap.tc.webdynpro.clientserver.session.ClientSession.doApplicationProcessing(ClientSession.java:666)
         at com.sap.tc.webdynpro.clientserver.session.ClientSession.doProcessing(ClientSession.java:250)
         at com.sap.tc.webdynpro.clientserver.session.RequestManager.doProcessing(RequestManager.java:149)
         at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doContent(DispatcherServlet.java:62)
         at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doPost(DispatcherServlet.java:53)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:401)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:266)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:387)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:365)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:944)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:266)
         at com.sap.engine.services.httpserver.server.Client.handle(Client.java:95)
         at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:175)
         at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
         at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
         at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
         at java.security.AccessController.doPrivileged(AccessController.java:215)
         at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100)
         at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170)

    Hello,
    we are having the save Exception.
    We are not working with modelNodes  only with valueNodes.
    We can reproduce the Exception, when doing the same as Daniel
    Daniel  Lam wrote:
    I get the exception after doing the following:
    1. The data from detailNode are displayed in a table.
    2. I changed the value of one the field to an invalid text and attempt to save the application. I got a validation error.
    3. I changed back to the original value and save again and i got the exception.
    How did you solve it?
    What are we doing wrong?`
    Can somebody help me please?

Maybe you are looking for