Subject Re: [firebird-support] store procedure sintax: declare cursor
Author Helen Borrie
At 08:58 AM 4/11/2008, you wrote:
>I'm using an 2.1 firebird server with a ODS 11.1 database but when I try to
>create a SP like this
>
>CREATE PROCEDURE p_n AS
>
>declare variable i_archivio varchar(8);
>declare variable i_id_archivio integer;
>declare variable i_vd2_codice varchar(8);
>declare variable i_vd3_codice varchar(8);
>
>declare variable FETCH_STATUS_Colors integer;
>declare variable FETCH_STATUS_Seqs integer;
>declare variable vd1_sequenza integer;
>declare variable vdc_sequenza integer;
>declare variable qta integer;
>declare variable str_sequenza char(3);
>declare variable str_qta char(6);
>declare variable str_sequenze varchar(100);
>declare variable str_qtas varchar(100);
>declare variable vd1_codice varchar(8);
>declare variable vd1_descrizione varchar(40);
>declare variable rows_counter integer;
>
>BEGIN
>
>i_id_archivio= 25;
>i_archivio= 'OVR';
>i_vd2_codice= 'SHIRT';
>i_vd3_codice= 'SPRT';
>
>declare variable Colors CURSOR FOR (SELECT vd1_codice, descrizione FROM vdq
>INNER JOIN vd1 ON (vd1.codice=vdq.vd1_codice) WHERE id_Archivio =
>i_id_archivio AND Archivio=i_archivio AND vd2_codice=i_vd2_codice GROUP BY
>vd1_codice, descrizione ORDER BY vd1_codice);
> ........
>
>END;
>
>I receive this error:
>
>Invalid token.
>Dynamic SQL Error.
>SQL error code = -104.
>Token unknown - line 28, column 1.
>declare.
>
>relative to instruction: declare variable Colors CURSOR FOR ......

Declarations have to be in the header of the module.

./heLen