Page 1 of 1

store procedure, how to get return value

Posted: 09.05.2010, 02:56
by pbrucco
How to get a return value from a stored procedure using the component tzreadonlyquery?

........
sp.ParamByName('turno').AsInteger := 0;
sp.ParamByName('fehora').AsString := 'x';
sp.ParamByName('codusuario').AsInteger := 99;
........
sp.ExecSQL;


the store procedure is:

create or alter procedure ADD_MOV (
ICODCLIENTE integer,
DFECHA date,
CTIPOPAGO char(1),
DIMPEX decimal(14,2),
DIMPMIN decimal(14,2),
DIMPMAX decimal(14,2),
ICODMOZO integer,
IMESA integer,
ICODTARJETA integer,
INROTALON integer,
ITURNO integer,
CFEHORA varchar(17),
ICODUSUARIO integer)
returns (
CSERIE char(1),
ICOMPROB integer)
as
begin
select a.serieb, a.boletas from numeros a into :cserie, :icomprob;
update numeros set boletas = boletas + 1;
insert into movimcli (codcliente, fecha, serie, comprob, tipopago, impex, impmin, impmax, codmozo, mesa, codtarjeta, nrotalon, turno, fehora, codusuario) values (:icodcliente, :dfecha, :cserie, :icomprob, :ctipopago, :dimpex, :dimpmin, :dimpmax, :icodmozo, :imesa, :icodtarjeta, :inrotalon, :iturno, :cfehora, :icodusuario);
end


y need the values of :cserie y :icomprob.

In the component, the params serie and comprob are the 13 and 14.

The :
cSerie:= spAgregarMovimcli.Params[13].AsString;
nComprob:= spAgregarMovimcli.Params[14].AsInteger;

not return any value

Can I help me? very thanks!!

(I have Lazarus 0.9.29 r23650 FPC 2.5.1 i386-win32-win32/win64 and Zeos 7.0.0dev of svn)

Posted: 09.05.2010, 09:52
by seawolf
Hi,
I did a simple test and it works nicely to me .. anyway your post is not complete so I could suggest:

1. the sql query
select p.cSerie,p.nComprob
from yourprocedure(:params) p;

2. add a SUSPEND command at the end of the procedure

Posted: 09.05.2010, 23:32
by pbrucco
Very thanks Seawolf!!. :up:
working properly

Re: store procedure, how to get return value

Posted: 24.10.2024, 11:31
by Bernard
Working properly
thanks