Unix Technical Forum

Equivalent query

This is a discussion on Equivalent query within the Informix forums, part of the Database Server Software category; --> Hello I have a question is there an equivalent of the "TOP" function of sql server in informix I ...


Go Back   Unix Technical Forum > Database Server Software > Informix

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-20-2008, 01:13 PM
luissol
 
Posts: n/a
Default Equivalent query

Hello

I have a question is there an equivalent of the "TOP" function of sql
server in informix

I need something like this but in the informix sintax:

DECLARE @var1 integer
SET @var1 = (select count(*) from table)
DECLARE @var2 integer
SET @var2 = 200
select top (@var1 - @var2) * from table

I'm using C# to develop my application that has access to informix but

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-20-2008, 01:13 PM
DORN B
 
Posts: n/a
Default Re: Equivalent query

TRY: SELECT FIRST <NUMBER OF ROWS> * FROM <TABLE>

On 4 Oct 2006 16:41:32 -0700, luissol <luissol@gmail.com> wrote:
>
> Hello
>
> I have a question is there an equivalent of the "TOP" function of sql
> server in informix
>
> I need something like this but in the informix sintax:
>
> DECLARE @var1 integer
> SET @var1 = (select count(*) from table)
> DECLARE @var2 integer
> SET @var2 = 200
> select top (@var1 - @var2) * from table
>
> I'm using C# to develop my application that has access to informix but
>
> _______________________________________________
> Informix-list mailing list
> Informix-list@iiug.org
> http://www.iiug.org/mailman/listinfo/informix-list
>


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-20-2008, 01:13 PM
=?iso-8859-1?q?Rich_or_Krist=EDn?=
 
Posts: n/a
Default Re: Equivalent query


luissol wrote:
> Hello
>
> I have a question is there an equivalent of the "TOP" function of sql
> server in informix


http://publib.boulder.ibm.com/infoce...53.htm#idx3051

>DECLARE @var1 integer
>SET @var1 = (select count(*) from table)
>DECLARE @var2 integer
>SET @var2 = 200
>select top (@var1 - @var2) * from table


You may want to read up on dynamic SQL within Informix too...

Rich

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-20-2008, 01:14 PM
Jonathan Leffler
 
Posts: n/a
Default Re: Equivalent query

luissol wrote:
> I have a question is there an equivalent of the "TOP" function of sql
> server in informix
>
> I need something like this but in the informix sintax:
>
> DECLARE @var1 integer
> SET @var1 = (select count(*) from table)
> DECLARE @var2 integer
> SET @var2 = 200
> select top (@var1 - @var2) * from table
>
> I'm using C# to develop my application that has access to informix but




Question for you? Are you aware that there is no particular order
inherent in the way the data is returned from the database? Or, put
another way, do you realize that even if we can agree that "SELECT TOP
30 * FROM SomeTable" can be achieved, then the contents you get is
indeterminate. If the table isn't fragmented and hasn't had any records
deleted, then you will probably get the data in the order it was
inserted - but that is far from guaranteed.

If you dive into the theory behind databases, you'll find that tables
are sets of rows, and sets do not have any order.


--
Jonathan Leffler #include <disclaimer.h>
Email: jleffler@earthlink.net, jleffler@us.ibm.com
Guardian of DBD::Informix v2005.02 -- http://dbi.perl.org/
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 08:37 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com