How do I get a resultant parameter from a stored procedure:
CREATE PROCEDURE PROC_DO_ICD
(INID_FLT T_IDENTITY
,INTY_ICD TY_SRC
,INID_ICD_TO T_IDENTITY
,INDE_DO_ICD T_DESCRIPTIONSHORT )
RETURNS
( OUTID_ICD_TO T_IDENTITY )
calling the below statement
EXECUTE PROCEDURE MY_PROC_DO_ICD 2, 2,0,"Invoice" RETURNING_VALUES :THERETURN
by
prm := qry.ParamByName('THERETURN');
prm.ParamType := ptOutput;
prm.DataType := ftInteger;
try
qry.ExecSQL;
except
on E : Exception do
giveup;
end;
Result := prm.AsInteger;
FreeAndNil(qry);
fails.
any ideas?
Kind Regards,
Robert.
:?:
Stored Procedure Output parameter
Moderators: gto, EgonHugeist, olehs
-
- Fresh Boarder
- Posts: 9
- Joined: 23.02.2010, 07:19
-
- Fresh Boarder
- Posts: 9
- Joined: 23.02.2010, 07:19
found the answer.
use TZStoredProc built for this very reason.
proc := TZStoredProc.Create(nil);
proc.StoredProcName := 'PROC_DO_ICD';
proc.ParamByName('INID_FLT').AsInteger := serverid;
proc.ParamByName('INTY_ICD').AsInteger := Ord(icd);
proc.ParamByName('INID_ICD_TO').AsInteger := ParentDoc;
proc.ParamByName('INDE_DO_ICD').AsString := icdDesc;
try
proc.ExecProc;
except
on E : Exception do
logErrorMessage(E.Message);
end;
prm := proc.Params.FindParam('OUTID_ICD_TO');
if( Assigned(prm))then
Result := prm.AsInteger;
FreeAndNil(proc);
use TZStoredProc built for this very reason.
proc := TZStoredProc.Create(nil);
proc.StoredProcName := 'PROC_DO_ICD';
proc.ParamByName('INID_FLT').AsInteger := serverid;
proc.ParamByName('INTY_ICD').AsInteger := Ord(icd);
proc.ParamByName('INID_ICD_TO').AsInteger := ParentDoc;
proc.ParamByName('INDE_DO_ICD').AsString := icdDesc;
try
proc.ExecProc;
except
on E : Exception do
logErrorMessage(E.Message);
end;
prm := proc.Params.FindParam('OUTID_ICD_TO');
if( Assigned(prm))then
Result := prm.AsInteger;
FreeAndNil(proc);