Limit the number of rows selected in a query
Posted in 1999
Topics: SQL Development & Query Writing, Connectivity: ESQL/C, 4GL & Embedded SQL
Does anyone know how to set the limit on the number of rows in a simple (Informix) SQL select statement or by Informix ESQL/C API? Thanks, Quang
try 'select first n from table...' according to release notes available from 7.30 In article <7r4di5$ogq1@newsflash.tibco.com>, Quang Ton-That <quang.tont hat@tibcofinance.com> writes >Does anyone know how to set the limit on the number of rows in a simple >(Informix) SQL select statement or by Informix ESQL/C API? > >Thanks, >Quang > > Andrew Lennard andy@kontron.demon.co.uk
Hello Quang. In 7.30 you can use SELECT FIRST to limit the number of rows returned. Otherwise you could use a CURSOR and manually count the number of rows either in an ESQL program or by using a Stored Proc. Regards Andy Grantham Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't.
If you have 7.3x use:
SELECT FIRST 43 .......
Since you are using ESQL/C you can always just close the cursor after
fetching the number of rows you want to fetch. The engine will only fill
the next communication transfer buffer (default size is 4K configured by
the global FetBufSize before the first OPEN statement in your program,
range 4K->(32K-1)) anyway so there will not be a huge amount of extra work
done on the server so this will work reasonably well on 7.[12]x.
Art S. Kagel
Quang Ton-That wrote:
>
> Does anyone know how to set the limit on the number of rows in a simple
> (Informix) SQL select statement or by Informix ESQL/C API?
>
> Thanks,
> Quang