🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.interbase.sql
Article #971

Re: Select from variable

#971
From: Wayne Niddery [TeamB]
Date: Mon, 02 Apr 2007 17:54
37 lines
2283 bytes
aleplgr wrote:
>
> 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;

This is fine, but you could combine this into a single statement:

 SELECT MIN(CLIENTID), MAX(CLIENTID)
 FROM TEMPORALPRUEBA1
 INTO :MINCLIENTID, :MAXCLIENTID;

> SELECT MAX(GENE) FROM TEMPORALPRUEBA1 WHERE
> CLIENTID = MINCLIENTID  INTO :IDMAX;
>
> and I'm getting the error
> Column unknown MINCLIENTID.

Because it thinks you are naming a column instead of a variable. In any SQL 
statement you must include the colon ot indicate local variables:

 ... WHERE CLIENTID = :MINCLIENTID  INTO :IDMAX;

> I'm writing the procedure in EMS SQL MANAGER 2005 for InterBase/
> firebird and I'm getting the error when I compile the procedure

This will work for Firebird, but these are InterBase groups. They are 
different products that are differing more with each release. You really 
should ask Firebird questions in Firebird newsgroups for the best answers on 
that product.

-- 
Wayne Niddery - Winwright, Inc (www.winwright.ca)
SpaceShipOne; GovernmentZero 
Technical Details
Message-ID: <46114349$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <46112987$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 114a0e,9d569d1fdba243ad
X-Google-Attributes: gid114a0e,public
X-Google-Language: ENGLISH,ASCII-7-bit
Reply-To: "Wayne Niddery [TeamB]" <wniddery@chaffaci.on.ca>
From: "Wayne Niddery [TeamB]" <wniddery@chaffaci.on.ca>
Newsgroups: borland.public.interbase.sql
References: <46112987$1@newsgroups.borland.com>
Subject: Re: Select from  variable
Date: Mon, 2 Apr 2007 13:54:17 -0400
Lines: 39
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3028
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3028
X-RFC2646: Format=Flowed; Original
NNTP-Posting-Host: 64.235.108.38
Message-ID: <46114349$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1175536457 64.235.108.38 (2 Apr 2007 10:54:17 -0800)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail