ado调用存储过程(100)

  • 主题发起人 主题发起人 sjg23690428
  • 开始时间 开始时间
S

sjg23690428

Unregistered / Unconfirmed
GUEST, unregistred user!
oracle数据库,下面代码执行成功,但是存储过程的参数值传不进去,delphi调用存储过程后,能返回数据 "工号不能为空",找了几天不知道什么原因,只有请求各位战友了,愿意送上100大洋function TSAdo.ExecProc(cmd, rst: OleVariant; const ProcName: string; var prms: THCDataValue): Boolean;var ResulStr: String;begin Result:= not (VarIsEmpty(FADOConn) or VarIsEmpty(cmd)) and (FADOConn.State = adStateOpen); if Result then begin try cmd.CommandText:= ProcName; cmd.CommandType := adCmdStoredProc; cmd.ActiveConnection:= FADOConn; cmd.Parameters.Append(cmd.CreateParameter('v_userid', adVarChar, AdParamInput, 4,'1006')); cmd.Parameters.Append(cmd.CreateParameter('v_pass', adVarChar, AdParamInput,4, '1006')); cmd.Parameters.Append(cmd.CreateParameter('v_clientno', adVarChar, AdParamInput,4,'1001')); cmd.Parameters.Append(cmd.CreateParameter('overtime', adDouble, AdParamInput,10,29)); cmd.Parameters.Append(cmd.CreateParameter('strresult', adVarChar, AdParamInputOutput,2,'OK')); cmd.Execute(NULL, NULL, adCmdStoredProc); ResulStr:= VarToStr(cmd.Parameters['strresult'].Value); showmessage(ResulStr); except Result:= False; end; end;end存储过程如下create or replace procedure xyj_work(V_USERID in varchar2, v_pass in varchar2, v_clientno in varchar2, overtime in number, strresult in out varchar2)as tresult varchar2(100) :=''; CARDCHECK exception;begin select sysdate into begintime from dual; insert into sjg1 (a1, a2, a3, a4)values (v_userid, v_pass, v_clientno, overtime); commit; if v_userid is null then tresult:= '工号不能为空'; raise CARDCHECK; end if; exception when CARDCHECK then begin strresult:= tresult; end; when others then begin strresult:= tresult; rollback; write_reg(nvl(v_userid,'9999'),tresult||'xyj_work',sqlerrm); end; end;
 
套了Begin....End;吗?
 
没有人知道吗?可以在加400分
 
在cmd.ActiveConnection:= FADOConn;后面加上这一句试:cmd.Parameters.Refresh;
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
893
import
I
S
回复
0
查看
928
SUNSTONE的Delphi笔记
S
后退
顶部