Re: Re: How to number rows in SQL?
Posted in 2004
Hey that's a very good idea ! I haven't thougt it.
I'm asigned to modify a program and I want to modify at least as possible.
In the middle of the program I'm modifying there is a temporary table that could be used the way said.
Thanks a lot.
Chucho!
PD: You're rigth about stored procedures in other situation I shall uded it.
-----Original Message-----
From: "Richard Harnden" <richard.harnden@lineone.net>
To: informix-list@iiug.org
Date: Wed, 21 Apr 2004 11:19:55 +0100
Subject: Re: How to number rows in SQL?
"Jean Sagi" <jeansagi@myrealbox.com> wrote in message
news:c64cc8$egj$1@terabinaries.xmission.com...
>
>
> Has anyone tryed to number the result set of a sql in dbaccess for
example?
>
> I mean:
>
> select <number> no, colA, colB, etc
> from some table
>
> What I want to be returned is :
>
> no colA colB etc
> -- ---- ---- ----
> 1 data data data
> 2 data data data
> 3 data data data
> 4 data data data
> 5 data data data
> 6 data data data
> .
You'll have to use a tempory table, with a serial column and insert zeros;
something like ...
CREATE TEMP TABLE xyzzy
(
id SERIAL,
tabid INTEGER
) WITH NO LOG;
INSERT INTO xyzzy
SELECT 0, tabid
FROM systables;
SELECT *
FROM xyzzy;
But, you won't be able to order by your colA, colB.
>
> I'm using IDS 9.3
>
> I know I could what I explained with a stored procedure, but I wonder if
there is a magical function or trick that could be used to achieve what I
want in sql.
A stored procedure is probably a better solution.
--
rh
Jean Sagi
jeansagi@myrealbox.com
jeansagi@netscape.net
sending to informix-list