Stored Procedure Output parameter

The alpha/beta tester's forum for ZeosLib 7.0.x series

Report problems concerning our Delphi 2009+ version and new Zeoslib 7.0 features here.

This is a forum that will be removed once the 7.X version goes into stable!!

Moderators: gto, EgonHugeist, olehs

Locked
sir.wally.lewis
Fresh Boarder
Fresh Boarder
Posts: 9
Joined: 23.02.2010, 07:19

Stored Procedure Output parameter

Post by sir.wally.lewis »

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.
:?:
sir.wally.lewis
Fresh Boarder
Fresh Boarder
Posts: 9
Joined: 23.02.2010, 07:19

Post by sir.wally.lewis »

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);
:chef:
Locked