搜索墙首页  编程技术  java  asp  ajax  php  c/c#/c++  数据库  oracle  mysql  db2  操作系统  windows  linux  股吧
首页 > 编程 > 数据库 > oracle
 1         
1楼  zyqyour 2007-03-26 10:49:29

create   or   replace   procedure   SP_callee(c1   in   out   sys_refcursor)   as
  v_errm   varchar2(256);
  v   int   :=     100;

  begin
  dbms_output.put_line( 'SP_callee   run! ');

  open   c1   for
  select   v   from   sys.dual;

  exception
  when   others   then
  v_errm   :=   SUBSTR(SQLERRM,   1,   256);
  DBMS_OUTPUT.PUT_LINE(   'error   code=[]: '   ||   v_errm);
  dbms_output.put_line( 'SP_callee   error! ');


  end   SP_callee;
  /

-------------------------------------------------------------

  create   or   replace   procedure   SP_caller(c1   in   out   sys_refcursor)   as
  v_errm   varchar2(256);

  begin
  dbms_output.put_line( 'SP_caller   run! ');

  sp_callee(c1);

  exception
  when   others   then
  v_errm   :=   SUBSTR(SQLERRM,   1,   256);
  DBMS_OUTPUT.PUT_LINE(   'error   code=[]: '   ||   v_errm);
  dbms_output.put_line( 'SP_caller   error! ');

  end   SP_caller;
  /

-------------------------------------------------------------------

  set   serverout   on;
  declare
  v_errm   varchar2(256);
  c1   sys_refcursor;
  v   int   :=     0;

  begin

  sp_caller(c1);

  fetch   c1   into   v;
  dbms_output.put_line(v);

    exception
    when   others   then
    DBMS_OUTPUT.PUT_LINE(   'error   ! ');
    v_errm   :=   SUBSTR(SQLERRM,   1,   256);
    DBMS_OUTPUT.PUT_LINE(   'error   code=[]: '   ||   v_errm);
   
    end;
 


为什么在SQLPLUS中运行时,得到下面的输出?

SP_caller   run!  
SP_callee   run!  
error   !  
error   code=[]:ORA-06504:   PL/SQL:   Return   types   of   Result   Set   variables   or   query   do   not   match  
PL/SQL   procedure   successfully   completed.
2楼  love_2008 2007-03-26 10:51:46

有什么好奇怪的     怎么了??
3楼  zyqyour 2007-03-26 10:55:46

为什么会报错啊?
c1不是int型的吗?那么“   fetch   c1   into   v”为什么会报错呢?
4楼  flyarry 2007-03-26 14:21:53

set   serverout   on;
  declare
  v_errm   varchar2(256);
  c1   sys_refcursor;           //是这个c1吧,这个cursor是什么样的?
  v   int   :=     0;
5楼  baojianjun 2007-03-26 14:27:24

c1不是INT类型的而是sys_refcursor类型的
6楼  hongqi162 2007-03-26 14:43:02

很遗憾   我用的是oracle9i


这是我执行后的结果。

SP_caller   run!
SP_callee   run!
100


7楼  hongqi162 2007-03-26 14:44:19

楼主这下该郁闷了
8楼  haisenmai 2007-03-27 19:06:15

期待解决!
 1         
您的发言将按有关规定都会存档,您须为所发表后果负责,请您遵纪守法并注意语言文明。
标题:oracle 的一个奇怪的问题.....................
热门关注
标题回复点击
Oracle 10g (ASM):Sample Implementation0743
Oracle 正版用户授权0692
动态性能视图(Dynamic perfermance view V$)0686
EM 无法启动&&重新完全配置EM0560
小布老师Oracle 9i DBA Fundamentals II0345
ORA-1652: unable to extend temp segment诊断以及解决0308
缓冲处理器 buffer handle0275
locate pl/sql bottleneck0271
OracleDBConsole 服务因 2 (0x2) 服务性错误而停止。请问一下如何解决!2267
L1:Buffer Cache0264
搜索墙@2009 www.pkwall.com all rights reserved QQ:276471788 [京ICP备09111534号]
声明:本站部分数据来源于网络,仅供参考,如有版权问题,请联系我们,我们将及时删除!转载本站请注明来源