上面是这样声明的 
TEMP CRMS_TEMP_BIZ_APPROVE_INFO%ROWTYPE下面是这样放到temp
select
trunc(reply_date) as reply_date ,
      report_date,
      APPROVE_ORG_CD into  temp 
from 表 。但是当 查询出没数据的时候,这里就会报个“没数据的错误”。要怎么解决这个问题呢

解决方案 »

  1.   

    在select into 之前,先做一个count()判断
      

  2.   

    temp是一条记录,不能随便赋值
    select 
    * into  temp 
    from 表 。 或select * into temp from
    (select 
    trunc(reply_date) as reply_date , 
          report_date, 
          APPROVE_ORG_CD into  temp 
    from 表)
      

  3.   

    后面那段写错了
    应该是先定义游标
    declare
    cusor cur is select 
        trunc(reply_date) as reply_date , 
            report_date, 
            APPROVE_ORG_CD 
        from 表 ;
    temp cur%rowtype;begin
    ...
      

  4.   

    不嫌麻烦的话,把查询语句写进一个CURSOR(游标)里,
    CURSOR CUR_查询
    is
    select 
    trunc(reply_date) as reply_date , 
          report_date, 
          APPROVE_ORG_CD into  temp 
    from 表 

    然后就是open cursor,
    fetch CUR_查询 into temp
    这个时候判断no_data_found,然后做没数据的处理。
    最后别忘close cursor
    这样其实有点烦,习惯了以后结构就感觉挺清晰的。