Page 1 of 1

Stored Procedure Output parameter

Posted: 08.11.2010, 08:05
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.
:?:

Posted: 09.11.2010, 02:05
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: