gpt4 book ai didi

java - 如何获取 Oracle SQL 查询中错误的位置?

转载 作者:塔克拉玛干 更新时间:2023-11-03 05:25:57 25 4
gpt4 key购买 nike

如何获取查询中错误的位置?

我需要在导致错误的查询字符串中获取位置,就像 sqlplus 那样:

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 中正确的搜索字符串)以下链接: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

关于java - 如何获取 Oracle SQL 查询中错误的位置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17532023/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com