store procedure, how to get return value

Forum related to Firebird

Moderators: gto, cipto_kh, EgonHugeist

Post Reply
pbrucco
Fresh Boarder
Fresh Boarder
Posts: 8
Joined: 08.02.2010, 22:33

store procedure, how to get return value

Post 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)
seawolf
Zeos Dev Team *
Zeos Dev Team *
Posts: 385
Joined: 04.06.2008, 19:50
Contact:

Post 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
pbrucco
Fresh Boarder
Fresh Boarder
Posts: 8
Joined: 08.02.2010, 22:33

Post by pbrucco »

Very thanks Seawolf!!. :up:
working properly
Post Reply