在存储过程中一段代码入下:
a number;  b varchar2; 
select max(a.ygzds) into a, max(b.jlbbh) into b
  from cs_data.cbsj@ww_data a, cs_data.yh_dnb@ww_data b
 where 
   a.yhdabh = b.yhdabh
   and a.jlbbh = b.jlbbh
   and b.fgsbh = fgsbh
   and b.yhdabh = yhdabh
   and a.cblxbh = cblxbh
   and a.ygzds is not null
 order by year_month desc, ygzds desc编辑时说什么没分组, 但把两个into去掉这条语句查询出来的确实只有一条信息,怎么把查询出来的两个字段值插到两个变量中呢? 解决马上给分.

解决方案 »

  1.   

    select max(a.ygzds) max(b.jlbbh),a, b 
      from cs_data.cbsj@ww_data a, cs_data.yh_dnb@ww_data b 
    where 
      a.yhdabh = b.yhdabh 
      and a.jlbbh = b.jlbbh 
      and b.fgsbh = fgsbh 
      and b.yhdabh = yhdabh 
      and a.cblxbh = cblxbh 
      and a.ygzds is not null 
    order by year_month desc, ygzds desc 
      

  2.   

    select max(a.ygzds), max(b.jlbbh) into a, b 
      from cs_data.cbsj@ww_data a, cs_data.yh_dnb@ww_data b 
    where 
      a.yhdabh = b.yhdabh 
      and a.jlbbh = b.jlbbh 
      and b.fgsbh = fgsbh 
      and b.yhdabh = yhdabh 
      and a.cblxbh = cblxbh 
      and a.ygzds is not null 
    order by year_month desc, ygzds desc 不好意思,上面的弄错了
      

  3.   

    还有一个,select ... into ...语句你要保证只会得到一条记录,要不会报错
      

  4.   

    我遇到的问题就是楼上所说的!!!
    select ...into...
    错误为:Error: PL/SQL: ORA-00934: group function is not allowed here
      

  5.   

    你那存储过程还有其他语句吗?
    错误为:Error: PL/SQL: ORA-00934: group function is not allowed here 
    这个经常是用的如COUNT,SUM函数而引起的啊
      

  6.   

    你这里写错了select max(a.ygzds) into a, max(b.jlbbh) into b 
    换成这个就可以了select max(a.ygzds), max(b.jlbbh) into a, b