Subject RE: [firebird-support] token unknown in stored procedure
Author Thomas Clarke
You have to create variables to hold the values in the select statement.

create procedure do_a_little(y integer)
returning_values (vara integer)
as
declare varb integer;
begin

for
select a, b
from c
where
x = :y
/* order by - a see my note below*/
into vara, varb
do
begin

/* Processing loop */
vara = varb * 2;

suspend;
end

end

Note the results of each row are place in the variables vara and varb
declared one as a returning variable and the other as a local variable. The
stored procedure runs through the begin-end once for each row returned by
the select statement.

Note I find it is usually better to order after I have called the stored
procedure as

select *
from do_a_little(100)
order by vara

I hope this helps.

Thomas Clarke

-----Original Message-----
From: newgen_315 [mailto:newgen_315@...]
Sent: Wednesday, March 30, 2005 8:00 PM
To: firebird-support@yahoogroups.com
Subject: [firebird-support] token unknown in stored procedure





hi all,

could someone please, spot why I'm getting an error at line 16,

; token unknown


it's probably obvious but I just do not see it. everything I try
gives that error.

thanks
Daniel

SET TERM ^;
CREATE PROCEDURE COUNTVEHTIRES
( AX_LES INTEGER,
IDVEH INTEGER )
RETURNS ( ALLCOUNT INTEGER
, SPARECOUNT INTEGER)
AS
DECLARE VARIABLE AX INTEGER;
BEGIN
AX = 0;
ALLCOUNT = 0;
SPARECOUNT = 0;

/* WHILE ( AX <= :AX_LES ) DO */
/* BEGIN */


SELECT * FROM AXLES
WHERE AXPOS = :AX
AND IDVEH = :IDVEH
error ==> ORDER BY AXPOS;

BEGIN
IF (AXPOS = 0) THEN
BEGIN
IF (POSRI > 0) THEN
BEGIN
ALLCOUNT = ALLCOUNT + 1;
SPARECOUNT = SPARECOUNT + 1;
END
IF (POSLI > 0) THEN
BEGIN
ALLCOUNT = ALLCOUNT + 1;
SPARECOUNT = SPARECOUNT + 1;
END
END
ELSE
BEGIN
IF (POSRO > 0) THEN
ALLCOUNT = ALLCOUNT + 1;
IF (POSRI > 0) THEN
ALLCOUNT = ALLCOUNT + 1;
IF (POSLO > 0) THEN
ALLCOUNT = ALLCOUNT + 1;
IF (POSLI > 0) THEN
ALLCOUNT = ALLCOUNT + 1;
END
AX = AX + 1;
END
SUSPEND;
END ^
SET TERM ;^











Yahoo! Groups Links