Good afternoon all. Unfortuantely, I am not a SQL guru. I am running into a problem that I think is specific to Firebird.
I am trying to create the following results from the following table

ID | NAME | PARENTID

1 | None | 0
4 | INSTs | 53
6 | IMPs | 53
7 | T-P | 6
19 | 2.MFG | 1
29 | IMPs | 19
40 | T-L | 29
53 | 1.Sales | 1

Result
ID | ParentNames
1 | None
4 | 1.Sales : INSTs
6 | 1.Sales : IMPs
7 | 1.Sales : IMPs : TP
19 | 2.MFG
29 | 2.MFG : IMPs
40 | 2.MFG : IMPs : T-L
53 | 1.Sales



A Query that I have tried, but seems to fail at the CAST portion is:

with recursive parentChildResult as
(
select ID,
NAME,
PARENTID,
cast(('' as varchar (max) as ParentNames)
from table_name
where PARENTID is null
union all
select i2.ID,
i2.NAME,
i2.PARENTID,
parentChildResult.ParentNames + ' > ' + parentChildResult.NAME
from QBCLASS as i2
inner join parentChildResult
on parentChildResult.ID = i2.PARENTID
)
select ID,
stuff(ParentNames, 1, 3, '') + ' > ' + NAME as ParentNames
from parentChildResult
where ID in
(
SELECT i.ID FROM table_name i
WHERE NOT EXISTS(SELECT 1 FROM QBCLASS I2 WHERE i.ID = I2.PARENTID)
)

order by ParentNames

Anyone have any idea what i need to do to make this query work? Please correct my language and concepts if I am using incorrect terminology or thinking. Again I am trying to query a Firebird database using SQL Workbench/J
Thank you in advance for all of your help.