调试经验——PL/SQL调试过程中可参考《Oracle Database Error Messages》加深对error的理解

问题描述:

工作中碰到SQL error,搞不懂的时候就会上网一顿狠查。但因为网文的质量参差不齐,难免会走弯路。今天发现了一个Oracle官方文档《Oracle Database Error Messages》(https://docs.oracle.com/cd/E11882_01/server.112/e17766/toc.htm),感觉是值得参考的。

如,运行以下PL/SQL代码,

--For Example ch11_1b.sql
DECLARE 
   CURSOR C_MyCursor IS
      SELECT *
        FROM zipcode
       WHERE state = 'NY';

会报错:

ORA-06550: line 6, column 26:
PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following:

   begin function pragma procedure subtype type <an identifier>
   <a double-quoted delimited-identifier> current cursor delete
   exists prior

推荐方法:

这时,可以在《Oracle Database Error Messages》中查看弹出的error message code,查到的结果如下:

ORA-06550: line string, column string: string
Cause: Usually a PL/SQL compilation error.
Action: None

PLS-00103: string
Cause: This error message is from the parser. It found a token (language element) that is inappropriate in this context.
Action: Check previous tokens as well as the one given in the error message. The line and column numbers given in the error message refer to the end of the faulty language construct.

通过阅读以上说明,我们可以对这两条error message有更深刻的理解,有助于提高调试效率并在今后避免错误。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值