首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > oracle >

问一个小小的pl/sql的procedure的小疑点.多谢。

2013-06-19 
问一个小小的pl/sql的procedure的小问题...谢谢。。。我正在写explicit cursor的procedure比如cursor testCur

问一个小小的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到这个变量不就得了

热点排行