I have this function which I use in an Informix database:

===============================================
CREATE FUNCTION informix.CHILD_TICKETS(CLAIM_ID DECIMAL)
RETURNING VARCHAR(255);
DEFINE v VARCHAR(12);
DEFINE l VARCHAR(255);
DEFINE i INTEGER;

ON EXCEPTION
RETURN 'ERROR';
END EXCEPTION

LET l = '';
LET i = 0;

FOREACH SELECT DETAIL_TICKET
INTO v
FROM CLAIMITEMS
WHERE DETAIL_CLAIM_ID = CLAIM_ID
ORDER by DETAIL_TICKET

LET i = i + 1;

IF i > 1 and v <> '' THEN
LET l = l || ',';
END IF

LET l = l || trim(v);

END FOREACH

RETURN l;
END FUNCTION;
===============================================


I can call it up from a SELECT statement and use it as a column (like so):
================================================== =====
SELECT CLAIM_NUMBER, CHILD_TICKETS(CLAIM_ID) FROM SAMPLECLAIMS
================================================== =====


The results obtained could look like so:
===============================================
CLAIM_NUMBER CLAIM_TICKETS
C001 11110138,11110138B
C002 11110139,11110139B,11110139C,11110139D
C003 11110154A
C004 11110181C,11110181E
===============================================


I tried converting this to Firebird as a procedure like so:
===============================================
CREATE OR ALTER PROCEDURE CHILD_TICKETS(CLAIM_ID DECIMAL)
RETURNS (DETAIL_TICKETS VARCHAR(255))
AS
DECLARE v VARCHAR(20);
DECLARE l VARCHAR(255) = '';
DECLARE i INTEGER = 0;
BEGIN
FOR SELECT DETAIL_TICKET
FROM CLAIMITEMS
WHERE DETAIL_CLAIM_ID = :CLAIM_ID
ORDER by DETAIL_TICKET
INTO :v
DO
BEGIN
if (v is null) THEN v = '';
if (v <> '') THEN i = i + 1;
if (i > 1 and v <> '') THEN l = l || ',';

l = l || trim(v);
END

DETAIL_TICKETS = l;
END;
===============================================

My problem here is I can't figure out how to call it in the same manner as the Informix example above. Please help.