Subject Re: [firebird-support] SELECT from variable
Author Alejandro Garcia
Thanks Gracias Jorge, now it works

Jorge Andres Brugger <jorge.brugger@...> escribió: SELECT MAX(GENE) FROM TEMPORALPRUEBA1 WHERE
CLIENTID = :MINCLIENTID INTO :IDMAX;

All references to non-table fields should be preceded by ":"

regards

Alejandro Garcia escribió:
> Hi! I'm writing a stored procedure, for this table:
>
> CREATE TABLE TEMPORALPRUEBA1 (
> CLIENTID INTEGER,
> DATE2 DATE,
> DATE1 DATE,
> GENE INTEGER NOT NULL);
>
>
> first I select the max and min CLIENTIDs and store them in the MAXCLIENTID and MINCLIENTID variables this works fine, although I'm not sure this is the way to do it:
>
> SELECT MAX(CLIENTID) FROM TEMPORALPRUEBA1 INTO :MAXCLIENTID;
> SELECT MIN(CLIENTID) FROM TEMPORALPRUEBA1 INTO :MINCLIENTID;
>
> But then I need to select using the variable MINCLIENTID as a condition and store it in the variable IDMAX:
>
> SELECT MAX(GENE) FROM TEMPORALPRUEBA1 WHERE
> CLIENTID = MINCLIENTID INTO :IDMAX;
>
> and I'm getting the error
> Column unknown MINCLIENTID.
>
> MINCLIENTID is the name of a variable in the procedure:
> DECLARE VARIABLE MAXCLIENTID SMALLINT;
> DECLARE VARIABLE MINCLIENTID SMALLINT;
>
> I'm writing the procedure in EMS SQL MANAGER 2005 for InterBase/ firebird and I'm getting the error when I compile the procedure
>
>
>
> ---------------------------------
>
> LLama Gratis a cualquier PC del Mundo.
> Llamadas a fijos y móviles desde 1 céntimo por minuto.
> http://es.voice.yahoo.com
>
> [Non-text portions of this message have been removed]
>
>
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> Visit http://www.firebirdsql.org and click the Resources item
> on the main (top) menu. Try Knowledgebase and FAQ links !
>
> Also search the knowledgebases at http://www.ibphoenix.com
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> Yahoo! Groups Links
>
>
>
>
>

--
Jorge Andres Brugger






---------------------------------

LLama Gratis a cualquier PC del Mundo.
Llamadas a fijos y móviles desde 1 céntimo por minuto.
http://es.voice.yahoo.com

[Non-text portions of this message have been removed]