4

我收到了臭名昭著的无效号码 Oracle 错误。Hibernate 正在发出一个包含很多列的 INSERT,我只想知道给出问题的列的名称。是否可以?

仅供参考,插入是这样的:

insert into GEM_INVOICE_HEADER 
   (ENDORSEE_ACCOUNT_ID, INVOICE_CODE, APPROVAL_ORGAN, APROVAL_DATE, APROVAL_REFERENCE, BALANCE_BASE_AMOUNT, BALANCE_DEDUCT_AMOUNT, BALANCE_TOTAL_AMOUNT, BALANCE_VAT_AMOUNT, BALANCE_VAT_DED_AMOUNT, BALANCE_VAT_NOT_DED_AMOUNT, DESCRIPTION, SUPPLIER_INVOICE_NUMBER, INVOICE_DATE, RECEIPT_DATE, MEMO, VAT_INTRACOM, INVOICE_BASE_AMOUNT, INVOICE_VAT_AMOUNT, INVOICE_VAT_DED_AMOUNT, INVOICE_VAT_NOT_DED_AMOUNT, INVOICE_DEDUCT_AMOUNT, INVOICE_TOTAL_AMOUNT, VAT_EXEMPT, RECTIFICATION_SIGN, REASON, LOT, FILE_ID, RETAINED, INSTITUTION_ID, PERIOD_CODE, IS_RECTIFIED, DEFAULT_OFFBUDGET_ACCOUNT, OFFBUDGET_DOC_ID, PHASE_OF_ACCOUNTING, ACCOUNTED_OFF_BUDGET, CANCEL_DOC_ID, BUDGET_TYPE, INVOICE_TYPE, SOURCE_ID, STATE_ID, MANAGER_UNIT_ID, DOCUMENT_TYPE_CODE, ACCOUNTED_DOC_ID, ACCOUNTING_LIST, ENDORSEE_ID, PAYMASTER_ID, SUPPLIER_ID, SUPPLIER_ACCOUNT_ID, PAY_JUSTIFY_ID, PETTY_CASH_ID, DBOID) 
values 
   (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
4

3 回答 3

6

尝试 DBMS_SQL.LAST_ERROR_POSITION

它会告诉你错误的 SQL 字符串中的字符位置。不知道它是否适用于 Hibernate,但它适用于 PL/SQL。

DECLARE
    v_ret NUMBER;
    v_text varchar2(10) := 'a';
BEGIN
    insert into a_test (val1, val2) values (1,v_text);
exception
    when others then 
        v_ret := DBMS_SQL.LAST_ERROR_POSITION;
        dbms_output.put_line(dbms_utility.format_error_stack);
        dbms_output.put_line('Error at offset position '||v_ret);
END;
.
/

请注意,“43”是“插入”的偏移量,忽略了任何前面的空格。

于 2010-02-25T22:06:40.623 回答
1

您需要 Oracle DML 错误日志记录。你的朋友是 err$_dest。

这可以告诉你哪一列失败了。

http://www.oracle-base.com/articles/10g/DmlErrorLogging_10gR2.php#insert

于 2010-03-19T03:00:25.287 回答
0

不幸的是,您无法让 Oracle 告诉您是哪一列导致了问题。您可以将插入数据转储为可以通过 sqlplus 手动运行的插入语句吗?

于 2010-02-25T17:21:37.657 回答