存储过程
create or replace procedure TestReturnValue
(
as_tjdw varchar2,
as_tjjd out varchar2, --统计进度标志
as_tjywcrq out varchar2, --统计源修改或完成日期
ai_return out number,
as_errmsg out varchar2
)
is
begin
as_tjjd := 'a';
as_tjywcrq := 'b';
ai_return := 1;
as_errmsg :='Return Nothing?';
end;
程序:
with lConnection do
try ConnectionString := 'DATABASEURL=Biz:\ZHAJ_DS\DSEZHAJ_TJSJK.Database';
Connected := True;
with Transaction do
begin
h := Start(False);
try
with TStoredProc.Create(nil) do
try
Connection := lConnection;
StoredProcName := TestReturnValue;
Params.Clear;
//统计单位
Params.CreateParam(TFieldType.ftString, 'as_tjdw', TParamType.ptInput);
//统计单位
Params.CreateParam(TFieldType.ftString, 'as_tjjd', TParamType.ptOutput);
Params.CreateParam(TFieldType.ftString, 'as_tjywcrq', TParamType.ptOutput);
Params.CreateParam(TFieldType.ftInteger, 'ai_return', TParamType.ptOutput);
Params.CreateParam(TFieldType.ftString, 'as_errmsg', TParamType.ptOutput);
Params.ParamByName('as_tjdw').AsString := '350802000000';
Execute;
ai_return := Params.ParamByName('ai_return').AsInteger;
as_errortext := Params.ParamByName('as_errmsg').AsString;
ls_progress := Params.ParamByName('as_tjjd').AsString;
jsDialogs.ShowMsg('Commit前:' + as_errortext, '提示');
jsDialogs.ShowMsg('Commit前:' + ls_progress, '提示');
jsDialogs.ShowMsg('Commit前:' + IntToStr(ai_return), '提示');
jsDialogs.ShowMsg('Commit前:' + Params.ParamByName('as_tjywcrq').AsString, '提示');
finally
Free;
end;
commit(h);
except
RollBack(h);
Raise;
end;
end
finally
Free;
end;
为什么我在Execute后,那些返回值都是空的?
这手动创建TStoredProc与事务会不会有什么问题?
是不是只在commit的时候,存储过程才真正的Execute?
但是如果我用控件StoredProc1 处理的话
返回值又是正常的??
with lConnection do
try
ConnectionString := 'DATABASEURL=Biz:\ZHAJ_DS\DSEZHAJ_TJSJK.Database';
Connected := True;
with Transaction do
begin
h := Start(False);
try
//with StoredProc1 do
try
StoredProcName := 'TestReturnValue';
Params.ParamByName('as_tjdw').AsString := '350802000000';
Execute;
ai_return := Params.ParamByName('ai_return').AsInteger;
as_errortext := Params.ParamByName('as_errmsg').AsString;
ls_progress := Params.ParamByName('as_tjjd').AsString;
jsDialogs.ShowMsg('Commit前:' + as_errortext, '提示');
jsDialogs.ShowMsg('Commit前:' + ls_progress, '提示');
jsDialogs.ShowMsg('Commit前:' + IntToStr(ai_return), '提示');
jsDialogs.ShowMsg('Commit前:' + Params.ParamByName('as_tjywcrq').AsString, '提示');
except
Raise;
end;
commit(h);
except
RollBack(h);
Raise;
end;
end
finally
Free;
end; |