I agree with you completely! It has to be relatively simple to implement.
And certainly it adds a very important missing functionality (for those who
can see it, that is).
Some kind of internal cursor has to iterate to return rows to the user after
the query is completely executed. This can add a counter (if it doesn't
have it already to compare again a possible LIMIT).
The only real problem is how do you return this to the user. If you put it
in a function, you have to syntactically exclude that function from
appearing anywhere except the select fields (not in WHERE, ORDER, GROUP or
whatever else.) I assume a special name or symbol (#, perhaps) would work.
(e.g.., SELECT # FROM table _or_ SELECT # AS row,* FROM table -- to give it
a name)
As for how useful it is, it depends on one's imagination! If some can't see
a reason for certain functionality, that's no reason for it not to be there.
Some do see a reason, and (please) don't call it a whim!
One good example was mentioned in someone else's reply, you need to add
ranks to a master table based on periodical results. Yes, you could use
temporary tables as intermediate storage but what if you have a table 100K
rows or more? Not very efficient, is it?
By the way, MySQL can do it very easily because of its variable manipulation
ability. (Something like SELECT @ROW:=@ROW+1 as ROW,* FROM table,(SELECT
@ROW := 0) foo; ) By since SQLite has not such capability, a poor man's
version could be implemented, as suggested.
Thanks to all for your contribution!
-----Original Message-----
From: Gabriel Corneanu
Sent: Monday, July 01, 2013 4:54 PM
To: sqlite-users@sqlite.org
Subject: Re: [sqlite] Is there a way to return the row number? (NOT
therowid)
As I don't think that the implementation is the problem, the real issues
are:
a) is it "lite" enough for the core? (I believe yes)
b) is a specific (non-standard) feature desired? (I don't have a
problem, but maintainers might have)
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users