From: John Bellardo <bellardo@cs...> - 2001-07-28 23:35:10
Seeing as it's the weekend, and I have nothing else to do with my
time ;-) I implemented LIMIT. Kudos to Ann for her good starting
The changes have been committed and should be in all builds >= 293. A
couple of warnings before I describe the current syntax. First, it has
not been well tested. The handful of queries I tried all work. I
wanted to get the changes into the hands of other for better testing.
For example, I have not tried LIMIT with bind variables or in stored
procedures. Second, using LIMIT provides no additional optimization.
It might reduce the amount of data transferred, but the syntax is
intended as a programming convenience, nothing more. Lastly, the
existing LIMIT syntax is subject to change until released in the next
official FB release (FB 1.0).
With that said, here is the syntax:
FIRST <value expression>
LIMIT (<value expression>[ ,<value expression>])
They work in the select statement after the join list and before the
select a aa, b bb, .... FROM table1 a, table2 b, .... [LIMIT(...) |
FIRST] WHERE ....
FIRST X tells FB to only return the first X rows from the result set.
LIMIT(X) functions identically as FIRST X.
LIMIT(X,Y) tells FB to return X rows of the result set starting at row
Y. Y is 1 based. So LIMIT(10,1) will return the first 10 rows from the
There is no syntax for LIMIT(ALL, 30), but the engine code exists to
handle it. If there is interest I'll add it. We need to decide if the
current LIMIT/FIRST syntax is what we want. I don't want to be changing
the syntax every other day, so lets talk about it, decide on it, and
then I'll change it :-).
In case anyone is interested the blr code I added was blr_skip X, which
skips to the Xth record in the stream. I did it that way for design
orthogonality with the existing blr_first blr code.
Lets get the ball rolling on testing so we can get FB1 out the door!