Oracle - 过程相关查询
我在 oracle 中编写以下查询:
DBMS_OUTPUT.....'Ashish'
Select col1 into val1 from tab_1
DBMS_OUTPUT.....'Ubale'
当我运行此过程时,我得到的输出为“Ashish”,为什么? 还有 v_val1 变量的值是什么
注意:该表不包含任何记录
I am writing the below queries in oracle:
DBMS_OUTPUT.....'Ashish'
Select col1 into val1 from tab_1
DBMS_OUTPUT.....'Ubale'
when I run this procedure I get the output as "Ashish" only why?
also what will be the value of v_val1 variable
Note: the table does not contain any records
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
由于表是空的,“select into”语句将引发 NO_DATA_FOUND 异常。这就是为什么您没有收到第二条消息的原因。 val1 将具有与选择之前相同的值 - 即如果您之前没有分配值,则为 null。
事实上,您不知道自己遇到了 NO_DATA_FOUND 异常,这表明您犯了 PL/SQL 开发人员曾经犯过的最大错误之一:
Since the table is empty, the "select into" statement will raise the NO_DATA_FOUND exception. That's why you don't get the second message. val1 will have the same value as before the select - i.e. null if you didn't previously assign a value.
The fact that you don't know you got the NO_DATA_FOUND exception suggests that you have made one of the biggest errors PL/SQL developers ever make:
你收到错误了吗?如果表中没有行。您可能会收到 no_data_found 异常。
顺便问一下,你的整个代码在哪里?
Did you get error? If the table doesn't have rows in it. You might get no_data_found exception.
By the way, where is your entire code?