Subject Re: [firebird-support] Re: How to return a string from a stored procedure?
Author Mark Rotteveel
On Wed, 07 Sep 2011 13:08:12 -0000, "firebirdsql" <firebirdsql@...>
wrote:
> The problem is that I need to run several SQL statements inside the
stored
> procedure that concatenates SQL strings and stores it in a variable. At
the
> end of the procedure, I just want to return that string.
>
> When I do the select from RDB$database at the end, firebird complains
> "multiple rows in singleton select"

That error message is pretty explicit about your problem: you are
performing a select which produces multiple rows and assigning it to
something which expects a single row.

> This is the sql I have:
>
> SELECT 'test' FROM table1 INTO :var1;
> SELECT 'test2' FROM table2 INTO :var2;

These one or both of these selects produce multiple rows, but you are
assigning it to a variable, so only 1 row is expected. Use RDB$DATABASE as
the table source. If this is an artificial simplification of your problem,
please try to create an SSCCE (see http://sscce.org/ ) which demonstrates
your actual problem.

> SELECT :var1 || :var2 FROM RDB$DATABASE INTO :return_variable;
> SUSPEND;

You don't need to use SUSPEND if you only have one result.