使用out参数执行Oracle Procedure

时间:2014-04-28 14:06:32

标签: .net oracle stored-procedures

我需要帮助调用具有2个输出参数的Oracle DB中的存储过程。我之前没有使用过参数,而且我也不熟悉Oracle。从.net网页调用查询时出现以下错误:

  

“ORA-00900:无效的SQL语句”

我收到了以下有关如何使用现有程序更新几个字段的说明:

In the P_API_BO_Vehicle package:
procedure ChangeLastMileage(pVehicleID T_FM_VEHICLE.F_VEH_ID%type,
                            pMileage T_FM_VEHICLE.F_VEH_LAST_MILE%type,
                            pDate T_FM_VEHICLE.F_VEH_LAST_DATE%type,
                            pErrorCode out binary_integer,
                            pErrorInfo out TErrorInfo);

所以我尝试了以下查询字符串:

VAR pErrorCode binary_integer 
VAR pErrorInfo TErrorInfo 
EXEC P_API_BO_Vehicle.ChangeLastMileage(18391, 20000, '2014-04-28', pErrorCode, pErrorInfo);

但是它给出了上面的错误。我是否在传递“Out”参数时做错了什么?

2 个答案:

答案 0 :(得分:0)

可能是PL / SQL开始..结束块可以帮助你

declare
    pErrorCode binary_integer;
    pErrorInfo TErrorInfo;
begin
  P_API_BO_Vehicle.ChangeLastMileage(18391, 20000, '2014-04-28', pErrorCode, pErrorInfo);
end;
/

或者你试图从C#环境中调用它?

答案 1 :(得分:0)

我设法让这个工作,我想我会给出答案包装任何人都有类似的问题。

declare
  pDate date; 
  pErrorCode binary_integer;
  pErrorInfo varchar2(500); 
begin 
  pDate := to_date('2014-04-28', 'YYYY-MM-DD'); 
  P_API_BO_Vehicle.ChangeLastMileage(18391, 20000, pDate, pErrorCode, pErrorInfo); 
end;