我在delphi里面用TADOStoredProc连接我在oracle数据库Package写的自定义的存储过程结果当delphi程序运行时候老是出现如下问题:提示Project packtest.exe raised exception class EOlException with message 'Application uses a value of the wrong type for the current operation' 。我对照了我的包申明还有delphi里面的参数表,类型是一致的,不知道到底是虾米原因,还请各位xdjm能解答,一点分数不足以感谢,无限感激在其中!!!
附该报存储过程的说明以及涉及调用包的delphi代码:
1。包申明: procedure GetAlarmInfo(id in varchar2,infotype in integer,requestid in varchar2,AInfo out varchar2,Ret out integer) is………………2。相关程序代码:
mytype := StrToInt(Edit3.Text);
id := Edit2.Text;
requestid := Edit4.Text;
myAdoConn.Connected :=false;
myAdoSp.ProcedureName := 'SMP_110QueryInfo.GetAlarmInfo';
myAdoConn.Connected := true;
myAdoSp.Parameters.Clear; myAdoSp.Parameters.CreateParamete('codeof110',ftString,pdInput,8,id); myAdoSp.Parameters.CreateParameter('infotype', ftInteger,pdInput,3,mytype);
myAdoSp.Parameters.CreateParameter('requestid',ftString,pdInput,14,requestid);
myAdoSp.Parameters.CreateParameter('AInfo',ftString,pdOutput,1024,'');
myAdoSp.Parameters.CreateParameter('Ret',ftInteger,pdOutput,2,''); try
myAdoSp.Prepared;
myAdoSp.ExecProc;
except
showmessage('访问数据库出错');
end;
ret := myAdoSp.Parameters.ParamByName('AInfo').Value;……………………………………
附该报存储过程的说明以及涉及调用包的delphi代码:
1。包申明: procedure GetAlarmInfo(id in varchar2,infotype in integer,requestid in varchar2,AInfo out varchar2,Ret out integer) is………………2。相关程序代码:
mytype := StrToInt(Edit3.Text);
id := Edit2.Text;
requestid := Edit4.Text;
myAdoConn.Connected :=false;
myAdoSp.ProcedureName := 'SMP_110QueryInfo.GetAlarmInfo';
myAdoConn.Connected := true;
myAdoSp.Parameters.Clear; myAdoSp.Parameters.CreateParamete('codeof110',ftString,pdInput,8,id); myAdoSp.Parameters.CreateParameter('infotype', ftInteger,pdInput,3,mytype);
myAdoSp.Parameters.CreateParameter('requestid',ftString,pdInput,14,requestid);
myAdoSp.Parameters.CreateParameter('AInfo',ftString,pdOutput,1024,'');
myAdoSp.Parameters.CreateParameter('Ret',ftInteger,pdOutput,2,''); try
myAdoSp.Prepared;
myAdoSp.ExecProc;
except
showmessage('访问数据库出错');
end;
ret := myAdoSp.Parameters.ParamByName('AInfo').Value;……………………………………
还有如果可以的话建议你使用ODAC,这样效率高很多
try
ADOStoredProc1.Close;
with ADOStoredProc1 do
begin
Connection := ADOConnection1;
Parameters.Clear;
ProcedureName := 'PKG_GDY_SHOW_PAGE.SHOW';
with Parameters.AddParameter do
begin
Name := 'iPagesize';
DataType := ftinteger;
Direction := pdInput;
size := 10;
Value := EDIT1.Text;
end;
with Parameters.AddParameter do
begin
Name := 'iCurrentpage';
DataType := ftinteger;
Direction := pdInput;
size := 10;
Value := EDIT2.Text;
end;
with Parameters.AddParameter do
begin
Name := 'strSql';
DataType := FTSTRING;
Direction := pdInput;
size := 500;
Value := sql;
end;
with Parameters.AddParameter do
begin
Name := 'iRecordCount';
DataType := FTinteger;
Direction := pdOutput;
Value := 0;
end;
with Parameters.AddParameter do
begin
Name := 'iPagenum';
DataType := FTinteger;
Direction := pdOutput;
Value := 0;
end;
with Parameters.AddParameter do
begin
Name := 'oFlag';
DataType := FTSTRING;
Direction := pdOutput;
size := 100;
Value := '';
end;
Open;
end;
except
showMessage('无法执行过程.');
end;
Edit4.Text := inttostr(ADOStoredProc1.Parameters.ParamValues['iRecordCount']);
Edit5.Text := inttostr(ADOStoredProc1.Parameters.ParamValues['iPagenum']);
Edit6.Text := ADOStoredProc1.Parameters.ParamValues['oFlag'];