我在通过 .NET 执行 Oracle 查询时遇到问题。我对从.Net调用Oracle命令很陌生(我来自mySQL背景),所以非常感谢任何帮助!
我首先构建一个查询字符串...
declare
pDate date;
pErrorCode binary_integer;
pErrorInfo varchar2(500);
begin
date := to_date(:Date, 'YYYY-MM-DD');
AnUpdateRoutine(:VehicleID, :ContractID, :DriverID, :pDate, :pDriverContribution, pErrorCode, pErrorInfo);
end;
然后我添加我的参数...
cmd2.Parameters.Add(":VehicleID", OracleDbType.Int32).Value = CInt(HiddenField.Get("ID"))
cmd2.Parameters.Add(":ContractID", OracleDbType.Int32).Value = CInt(HiddenField.Get("ContractID"))
cmd2.Parameters.Add(":DriverID", OracleDbType.Int32).Value = CInt(cbCurrentDriver.Value)
cmd2.Parameters.Add(":pDate", OracleDbType.Date).Value = Date.Now()
cmd2.Parameters.Add(":pDriverContribution", OracleDbType.NVarchar2).Value = DBNull.Value
cmd2.Parameters.Add("pErrorCode", OracleDbType.NVarchar2).Value = 0
cmd2.Parameters.Add("pErrorInfo", OracleDbType.NVarchar2).Value = 0
cmd2.ExecuteNonQuery()
在 ExecuteNonQuery() 调用中出现异常... ORA-01036: 非法变量名称/编号
过程的定义
procedure AnUpdateRoutine(pVehicleID in T_FM_VEHICLE.F_VEH_ID%type,
pContractID in T_FM_CONTRACT.F_CON_ID%type,
pDriverID in T_FM_DRIVER.F_DVR_ID%type,
pDateTimeOn in date,
pDriverContribution in T_FM_DRIVER_CHG.F_DCH_DVR_CONTRIBUTION%type,
pErrorCode out binary_integer,
pErrorInfo out TErrorInfo);
pVehicleID、pContractID、pDriverID 和 pDateTimeOn 是强制性的。