Subject | Re: [firebird-support] store procedure sintax: declare cursor |
---|---|
Author | Alan.Davies@aldis-systems.co.uk |
Post date | 2008-11-04T09:41:09Z |
You have the cursor declaration in the wrong place. All declarations
must come before the body of the procedure. Think of it as trying to
use a variable in C or Delphi before its been declared. You may still
get an error relating to the cursor declaration but that will be for a
different reason, e.g. I can't see what you base your GROUP BY on and
you would get this error - Invalid expression in the select list (not
contained in either an aggregate function or the GROUP BY clause).
Hope this helps.
Alan
--
Alan J Davies
Aldis
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;
declare 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);
BEGIN
i_id_archivio= 25;
i_archivio= 'OVR';
i_vd2_codice= 'SHIRT';
i_vd3_codice= 'SPRT';
then insert your procedure details here
........
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 ......
must come before the body of the procedure. Think of it as trying to
use a variable in C or Delphi before its been declared. You may still
get an error relating to the cursor declaration but that will be for a
different reason, e.g. I can't see what you base your GROUP BY on and
you would get this error - Invalid expression in the select list (not
contained in either an aggregate function or the GROUP BY clause).
Hope this helps.
Alan
--
Alan J Davies
Aldis
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;
declare 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);
BEGIN
i_id_archivio= 25;
i_archivio= 'OVR';
i_vd2_codice= 'SHIRT';
i_vd3_codice= 'SPRT';
then insert your procedure details here
........
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 ......