Subject | Re: token unknown in stored procedure |
---|---|
Author | Adam |
Post date | 2005-03-31T00:46:59Z |
Hi Daniel
Just a couple of things to note.
Select * -> Name the fields you want, its good practice
Does the select always guarantee to return exactly 1 record? If not,
you probably need to consider "for select" style.
Inside a SP, you will need use "into :var1" syntax on your selects.
eg:
declare variable customername varchar(100);
begin
for select name
from customer
into :customername
do
begin
-- do whatever
end
end
^
Otherwise the while statement is commented out, but not the
corresponding end statement.
Adam
--- In firebird-support@yahoogroups.com, "newgen_315"
<newgen_315@y...> wrote:
Just a couple of things to note.
Select * -> Name the fields you want, its good practice
Does the select always guarantee to return exactly 1 record? If not,
you probably need to consider "for select" style.
Inside a SP, you will need use "into :var1" syntax on your selects.
eg:
declare variable customername varchar(100);
begin
for select name
from customer
into :customername
do
begin
-- do whatever
end
end
^
Otherwise the while statement is commented out, but not the
corresponding end statement.
Adam
--- In firebird-support@yahoogroups.com, "newgen_315"
<newgen_315@y...> wrote:
>
>
> 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 ;^