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

oracle如何调用带参数的存储过程
我用的navicat for oracle连接的数据库

网上找了一个例子

create or replace procedure output_date is
begin
dbms_output.put_line(sysdate);
end output_date;

call output_date(); 不带参数的这样执行是对的

但是如果带参数,例如

create or replace procedure get_username(v_id in number,v_username out varchar2)
as
begin
  select username into v_username from tab_user where id = v_id; --变量赋值
exception
when no_data_found then
raise_application_error(-20001,'ID不存在!');
end get_username;


call get_username(1,'a');

出错提示

[SQL] call GET_USERNAME(1,'a')
[Err] ORA-06577: output parameter not a bind variable

应该如何调用呢?
过程是没有问题的,不执行语句而在过程上右键执行输入参数可以直接返回结果。



------解决方案--------------------
v_username out varchar2

你先改成

v_username in varchar2

应该就可以执行了

差别就在in 和 out~~ 百度下 就知道区别啦~ out是要带回来的
我的异常网推荐解决方案:oracle存储过程,http://www.aiyiweb.com/oracle-develop/177537.html