pl/sql中的select into问题

weiweipxb 2011-02-21 02:25:57
我一个触发器中很多个select into 语句,我想在每一个select into语句后面跟一个 exception when no_data_found then 来去除没有记录的情况。但是当我写了两个 select account_mon,bill_type into lsmon,lstype from flow_bill_m where bill_No = :new.bill_no and rownum = 1;
exception when no_data_found then
null;
select mod_date into closedate from bill_ctl where monthly = lsmon ;
exception when no_data_found then
null;
就出现错误pls-00103错误,发现附后exception当你等待下一个事件时:begin case declare and exit for goto if loop mod null pragma raise return select update when while with <ID>



请教大家纠结了好久啊
...全文
404 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
zh_666 2011-02-22
  • 打赏
  • 举报
回复
支持5楼的说法
minitoy 2011-02-21
  • 打赏
  • 举报
回复
被你雷到了.
按照上面再嵌套就是了.
或者
你可以先select count(*)判断下是否有数据,然后做if else嵌套.

不过怀疑的逻辑有问题.详细描述下?

[Quote=引用 4 楼 weiweipxb 的回复:]
那我有六七个select into这样嵌套不知道怎么搞啊
[/Quote]
weiweipxb 2011-02-21
  • 打赏
  • 举报
回复
那我有六七个select into这样嵌套不知道怎么搞啊
minitoy 2011-02-21
  • 打赏
  • 举报
回复
块的基本结构是
declare

begin

exception

end;
嵌套只能在块级进行.
直接在exception里再次exception是不成的
minitoy 2011-02-21
  • 打赏
  • 举报
回复
 
SQL> truncate table t_test_dml;

Table truncated

SQL> set serveroutput on
SQL>
SQL> declare
2 v_num number;
3 begin
4 select id into v_num from t_test_dml;
5 exception
6 when no_data_found then
7 begin
8 dbms_output.put_line('first');
9 select id into v_num from t_test_dml;
10 exception
11 when no_data_found then
12 dbms_output.put_line('second');
13 end;
14 end;
15 /

first
second

PL/SQL procedure successfully completed

SQL>
QKForex 2011-02-21
  • 打赏
  • 举报
回复
帮楼主顶。不过看了一下,oracle解释的是网络问题。

17,086

社区成员

发帖
与我相关
我的任务
社区描述
Oracle开发相关技术讨论
社区管理员
  • 开发
  • Lucifer三思而后行
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧