如何在Oracle SQL查询中获得错误的位置? [英] How can I get position of an error in Oracle SQL query?
本文介绍了如何在Oracle SQL查询中获得错误的位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何获取查询中错误的位置?
How can I get position of an error in the query?
我需要在导致错误的查询字符串中获取位置,就像sqlplus
那样:
I need to get position in a query string which causes an error, like sqlplus
does it:
SQL> insert into tbl (data) values('12345')
2 /
insert into tbl (data) values('12345')
*
ERROR at line 1:
ORA-12899: value too large for column "schmnm"."tbl"."data" (actual: 5,
maximum: 3)
我该怎么做?
推荐答案
经过一段漫长的旅行,当我差点失去希望时,我发现了以下链接(感谢Google中正确的搜索字符串):
After some ramblings when I almost lost hope, I found (thanks to correct search string in Google) following link: https://forums.oracle.com/thread/1000551
SQL> DECLARE
2 c INTEGER := DBMS_SQL.open_cursor ();
3 BEGIN
4 DBMS_SQL.parse (c, 'select * form dual', DBMS_SQL.native);
5
6 DBMS_SQL.close_cursor (c);
7 EXCEPTION
8 WHEN OTHERS THEN
9 DBMS_OUTPUT.put_line ('Last Error: ' || DBMS_SQL.LAST_ERROR_POSITION ());
10 DBMS_SQL.close_cursor (c);
11 RAISE;
12 END;
13 /
Last Error: 9
DECLARE
*
ERROR at line 1:
ORA-00923: FROM keyword not found where expected
ORA-06512: at line 11
这篇关于如何在Oracle SQL查询中获得错误的位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文