Subject | Re: [firebird-support] select *at least* N rows |
---|---|
Author | livius |
Post date | 2018-03-23T19:25:31Z |
Hi,
i know that you got the answer but, maybe this trick is interesting for
you
because it is simplest for use in any query but require creation of one
simple procedure.
I use it always in situation like you with fixed numbers of rows with
nulls
---------------------------------------------------------------------------------------------
CREATE PROCEDURE GEN_ROWS(IN_COUNT INTEGER) RETURNS (OUT_NO INTEGER)
AS
DECLARE VARIABLE VAR_I INTEGER;
BEGIN
VAR_I=1;
WHILE (VAR_I<=IN_COUNT) DO
BEGIN
OUT_NO=VAR_I;
VAR_I=VAR_I + 1;
SUSPEND;
END
END
---------------------------------------------------------------------------------------------
and now you can use it in select simply
---------------------------------------------------------------------------------------------
SELECT
W.*
FROM
GEN_ROWS(10) G
LEFT JOIN YOUR_TABLE W ON G.OUT_NO=1
ORDER BY G.OUT_NO, your_other_fields
ROWS 10
---------------------------------------------------------------------------------------------
Best Regards,
Karol Bieniaszewski
Sent: Friday, March 23, 2018 7:29 PM
Subject: RE: [firebird-support] select *at least* N
rows
Thank you very much Mark and András!!!
I've tried András solution... I replaced (mechanically, without
undestanding too much what was going on...) and it did the trick
perfectly!
Now is time to study a bit more and try to understand András answer
:)
Thanks a million again!!!