Subject Re: [firebird-support] Firebird SP Question
Author Lucas Franzen
Myles,

myles@... schrieb:
> Is it possible to have a stored procedure in FB execute two separate SELECT
> statements, and return a merged set of results back? Forgive me being a
> newbie to creative SELECT statements in SQL, but I have a set of data that I
> can get with one select statement, and then another set of data from the
> same table with another SELECT statement, and I want to return these back
> from the stored procedure in a sorted order so that the first set of results
> appear first, and the 2nd set of results are 'appended' onto the set.

I don't really get what you want, but of course you can have several
select statetments in a stored procedure.
Which way the result is returned is depending on the placement of the
SUSPEND command within your sp.

For example doing a select this way:

FOR SELECT <FIELDS> from TABLE1
INTO <return_variables>
DO BEGIN
FOR SELECT <FIELDS> from TABLE2
INTO <return_variables>
DO BEGIN
SUSPEND;
END
END

will give you a resultset which is just a join of table1 and table2.

If you have a select like this:

FOR SELECT <FIELDS> from TABLE1
INTO <return_variables>
DO BEGIN
SUSPEND;
END

FOR SELECT <FIELDS> from TABLE2
INTO <return_variables>
DO BEGIN
SUSPEND;
END

will retunr you all records from table1 with no values for table2 and
then all records from table2 (with the values from the last record of
table1).
This doesn't seem to be anything that anyone might want, but should give
you the idea.

Luc.