Subject RE: [firebird-support] Return string instead of multile records from SP
Author Svein Erling Tysvær
>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