Subject Re: Return string instead of multile records from SP
Author venussoftop
--- In firebird-support@yahoogroups.com, Svein Erling Tysvær <svein.erling.tysvaer@...> wrote:
>
> >Hi all
> >
> >I have a stored procedure (pasted below). Essentially it will return 1 or more records
> >(mA.cName in this initial case). What I really need to do is return a blob with the
> >records mA.cName as one big concatenated string of all the records returned in the
> >present version. What do I need to do further, please advise
>
> If you're on a recent Firebird version, I'd expect using the list function is all that is required:
>
> SELECT list(mA.cName)
> ...
>
> If it is an old version, try something like (beware of syntax errors)
>
> SET TERM ^ ;
> CREATE PROCEDURE RECEIPTNARRATIONACCOUNTS (
> TITRID ID,
> TISRFID ID )
> RETURNS (
> TCNAME CHAR60 )
> AS
> DECLARE VARIABLE TMP CHAR60;
> BEGIN
> TCNAME = '';
> FOR SELECT mA.cName
> FROM tReceipt tR
> JOIN sReceiptFooter sRF
> ON sRF.iPID = tR.iID
> JOIN mAccounts mA
> ON mA.iID = sRF.iAccountID
> WHERE tR.iID = :titRID AND sRF.iID <> :tisRFID
> INTO :TMP
> DO
> BEGIN
> tcName=tcName||', '||TMP;
> END
> SUSPEND;
> END^
> SET TERM ; ^
>
> HTH,
> Set
>

Thanks a lot Svein. I tried the LIST and it seems to return a blob as required.

But I need to further post process this result in my front end. I cannot make it work like this, any further suggestions
SELECT ... trim(tr.mremarks) || (EXECUTE PROCEDURE ReceiptNarrationAccounts(72, 117)) ....

Any suggestions on how I can just get the string here now?

Thanks and regards
Bhavbhuti