English 中文(简体)
如何确定哪些价值造成错误?
原标题:Debugging Oracle bulk DML error - how to determine which value caused the error?

I am trying to debug a DML error that is happening in one environment, but not others. The set up is this:

我有大约10套DML业务(从遥远的桌旁推到散装到当地桌上),其中2套给DML差错,“印数”fl,另一套是“PL/SQL:数字或数值错误:Bulk Bind:Truncated Bind”。

我尝试将数据复制到“良好”环境,不能复制同样的错误。 因此,我现在试图建立更强大的错误手,以赶上这些错误,并帮助确定哪些数据给我带来问题。

我期望:

...
loop
    fetch c_some_data bulk collect into v_arr limit v_limit_size;

    forall i in 1..v_arr.count SAVE EXCEPTIONS
    insert into table_abc_1 values v_arr(i);
    exit when c_some_data%notfound;
end loop;
...
exception
    when X_DML_ERRORS then
        declare
            j integer;
        begin
            FOR j IN 1 .. SQL%BULK_EXCEPTIONS.COUNT LOOP
                begin
                   /*only print the KEY fields for this table,
                   this table has (I think) close to 20 fields*/
                   dbms_output.put_line( DML Bulk-operation error:   ||
                                                           Error Code:  ||SQLERRM(-SQL%BULK_EXCEPTIONS(j).ERROR_CODE)|| ;  ||
                                                         v_arr(SQL%BULK_EXCEPTIONS(j).ERROR_INDEX).stage|| ;  ||
                                                         v_arr(SQL%BULK_EXCEPTIONS(j).ERROR_INDEX).id|| ;  ||
                                                         v_arr(SQL%BULK_EXCEPTIONS(j).ERROR_INDEX).code|| ;  )

                end;

            end loop;
        end;
    when others then
        PKG_EXCPTN.sp_generic_exception_handler;
end;

I m sure I could just print all of the columns, but the tables are large (some with > 20 columns) and there are 10 blocks of code that could potentially have this problem. It would also require someone to look at each value in the message and see if it matches with the column type (varchar2 vs. number).

是否容易印刷错误发生地和造成错误的价值?

(使用Oracle 10g)

最佳回答

您可以使用LOG ERRORS INTO在阁下的DML声明中,这将使你能够把错误和坏数据丢到一张桌子上,以便你稍后能够检查。

见:

http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_9014.htm#BGBDIGAH”rel=“nofollow” http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_9014.htm#BGBDIGAH

问题回答

暂无回答




相关问题
Export tables from SQL Server to be imported to Oracle 10g

I m trying to export some tables from SQL Server 2005 and then create those tables and populate them in Oracle. I have about 10 tables, varying from 4 columns up to 25. I m not using any constraints/...

Connecting to Oracle 10g with ODBC from Excel VBA

The following code works. the connection opens fine but recordset.recordCount always returns -1 when there is data in the table. ANd If I try to call any methods/properties on recordset it crashes ...

How to make a one to one left outer join?

I was wondering, is there a way to make a kind of one to one left outer join: I need a join that matches say table A with table B, for each record on table A it must search for its pair on table B, ...

Insert if not exists Oracle

I need to be able to run an Oracle query which goes to insert a number of rows, but it also checks to see if a primary key exists and if it does, then it skips that insert. Something like: INSERT ALL ...

How can I store NULLs in NOT NULL field?

I just came across NULL values in NOT-NULL fields in our test database. How could they get there? I know that NOT-NULL constraints can be altered with NOVALIDATE clause, but that would change table s ...

Type reference scope

I m studying databases and am currently working on a object-relational DB project and I ve encountered a small problem with the number of possible constraints in an object table. I m using "Database ...

OracleParameter and DBNull.Value

we have a table in an Oracle Database which contains a column with the type Char(3 Byte). Now we use a parameterized sql to select some rows with a DBNull.Value and it doesn t work: OracleCommand ...

热门标签