oracle_plsql_out_parametes

  前天,调用plsql过程出错,今天测试了一下oracle plsql 的out 参数:

测试用例:

  CREATE OR REPLACE PROCEDURE zp_for_test(in_month NUMBER,v_err OUT VARCHAR2) IS
  BEGIN

  ----
  END  zp_for_test;

测试结果:

Connected to Oracle Database 10g Enterprise Edition Release 10.2.0.4.0
Connected as hbkf_crm
 
SQL> exec zp_for_test(201203,'');
 
begin zp_for_test(201203,''); end;
 
ORA-06550: line 2, column 26:
PLS-00363: expression '' cannot be used as an assignment target
ORA-06550: line 2, column 7:
PL/SQL: Statement ignored
 
SQL> exec zp_for_test(201203,:v_out);
 
begin zp_for_test(201203,:v_out); end;
 
ORA-01008: not all variables bound
 
SQL> exec zp_for_test(201203);
 
begin zp_for_test(201203); end;
 
ORA-06550: line 2, column 7:
PLS-00306: wrong number or types of arguments in call to 'ZP_FOR_TEST'
ORA-06550: line 2, column 7:
PL/SQL: Statement ignored
 
SQL> exec zp_for_test(201203,'0');
 
begin zp_for_test(201203,'0'); end;
 
ORA-06550: line 2, column 26:
PLS-00363: expression '0' cannot be used as an assignment target
ORA-06550: line 2, column 7:
PL/SQL: Statement ignored
 
SQL> exec zp_for_test(201203,'11');
 
begin zp_for_test(201203,'11'); end;
 
ORA-06550: line 2, column 26:
PLS-00363: expression '11' cannot be used as an assignment target
ORA-06550: line 2, column 7:
PL/SQL: Statement ignored
 
SQL> exec zp_for_test(201203,'abc');
 
begin zp_for_test(201203,'abc'); end;
 
ORA-06550: line 2, column 26:
PLS-00363: expression 'abc' cannot be used as an assignment target
ORA-06550: line 2, column 7:
PL/SQL: Statement ignored
 
SQL>  exec zp_for_test(201203,'abc');
 
begin zp_for_test(201203,'abc'); end;
 
ORA-06550: line 2, column 26:
PLS-00363: expression 'abc' cannot be used as an assignment target
ORA-06550: line 2, column 7:
PL/SQL: Statement ignored
 
SQL> exec zp_for_test(201203,null);
 
begin zp_for_test(201203,null); end;
 
ORA-06550: line 2, column 26:
PLS-00363: expression ' NULL' cannot be used as an assignment target
ORA-06550: line 2, column 7:
PL/SQL: Statement ignored
 
SQL> exec zp_for_test(201203,);
 
begin zp_for_test(201203,); end;
 
ORA-06550: line 2, column 26:
PLS-00103: Encountered the symbol ")" when expecting one of the following:

   ( - + case mod new not null others <an identifier>
   <a double-quoted delimited-identifier> <a bind variable> avg
   count current exists max min prior sql stddev sum variance
   execute forall merge time timestamp interval date
   <a string literal with character set specification>
   <a number> <a single-quoted SQL string> pipe
   <一个带有字符集说明的可带引号的字符串文字>
   <一个可带引号的 SQL 字符串>
The symbol "null" was
 
SQL> exec zp_for_test(201203);
 
begin zp_for_test(201203); end;
 
ORA-06550: line 2, column 7:
PLS-00306: wrong number or types of arguments in call to 'ZP_FOR_TEST'
ORA-06550: line 2, column 7:
PL/SQL: Statement ignored
 
SQL>call
SQL> zp_for_test(in_month => :in_month,
  2                v_err => :v_err);
 
zp_for_test(in_month => :in_month,
              v_err => :v_err)
 
ORA-00900: invalid SQL statement

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

最后还是没有找到解决的方法,上网google了半天,解决方法都是,将其做为子程序调用。

eg.

You can call your procedure like this

declare
p1 varchar2(20);
p2 varchar2(3);
begin
zp_for_test(p1,p2);
end;

转载于:https://www.cnblogs.com/Alex-Zeng/archive/2012/04/23/2466160.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值