日期:2014-05-17  浏览次数:20663 次

问一个小小的pl/sql的procedure的小问题...谢谢。。。
我正在写explicit cursor的procedure

比如
  cursor testCursor is
  select name,id,cost
  from table1,table2
  where table1.id=table2.id;
  
  testRow  testCursor%rowtype;

  linecount:=0;
  open testCursor;
  loop
  fetch testCursor
  into testRow;
  exit when testCursor%notfound;
  linecount:=linecount+1;
  然后我要output的话,我就用dbms_output.put_line(testRow.name...);等等。。。
  end loop;
  这个是普通情况
  

  但是我现在要写的procedure里面我要用一个sum
  
  cursor testCursor is
  select sum(cost)"total"
  from table1,table2
  where table1.id=table2.id;

  testRow testCursor%rowtype;
这个时候我如何把这个sum的值output出来啊?
我胡乱试了dbms_output.put_line(testRow.sum(cost));
        dbms_output.put_line(testRow.total);
     
这些都不行,请假下该怎么output啊。。。

谢谢!

------解决方案--------------------
直接 定义个number型的变量,into到这个变量不就得了