錯誤在確定的行中時是否有可能發生異常?是否可以在PL/SQL中對精確行進行異常處理?
例如,這是我的代碼片段:
l_XMLvalue := l_xmltype.extract('/SHOW_SHIPMENT_005/DATAAREA/SHOW_SHIPMENT/SHIPMENT/SHIPITEM/QUANTITY/VALUE/text()').getStringVal();
dbms_output.put_line('QUANTITY: '||l_XMLvalue);
l_XMLdocument_id := l_xmltype.extract('/SHOW_SHIPMENT_005/DATAAREA/SHOW_SHIPMENT/SHIPMENT/SHIPITEM/DOCUMNTREF/DOCUMENTID/text()').getStringVal();
dbms_output.put_line('DOCUMENT ID:' ||l_XMLdocument_id);
l_XMLdoc_release := l_xmltype.extract('/SHOW_SHIPMENT_005/DATAAREA/SHOW_SHIPMENT/SHIPMENT/SHIPITEM/DOCUMNTREF/USERAREA/DOCUMENTRELEASE/text()').getStringVal();
dbms_output.put_line('DOCUMENT RELEASE:' ||l_XMLdoc_release);
l_XMLlinenum := l_xmltype.extract('/SHOW_SHIPMENT_005/DATAAREA/SHOW_SHIPMENT/SHIPMENT/SHIPITEM/DOCUMNTREF/LINENUM/text()').getStringVal();
dbms_output.put_line('LINE NUMBER:' ||l_XMLlinenum);
l_XMLsch_lnum := l_xmltype.extract('/SHOW_SHIPMENT_005/DATAAREA/SHOW_SHIPMENT/SHIPMENT/SHIPITEM/DOCUMNTREF/SCHLINENUM/text()').getStringVal();
dbms_output.put_line('SCHIPMENT LINE NUMBER:' ||l_XMLsch_lnum);
當函數提取正在試圖獲取價值,會有NULL,該程序將停止。這是可能的例外:
WHEN SELF_IS_NULL THEN
dbms_output.put_line('There is a problem with empty values in XML file');
這是我想做的事情是檢查在哪一行發生錯誤,並寫異常其準確值是錯誤。