Hi all, I've been working on a recursive query (I've already written a few, so I'm not a complete newbie..
All of the code below is available on the fiddle here: https://dbfiddle.uk/?rdbms=postgres_13&fiddle=0cc20c9081867131260e6e3550bd08ab I have a table called line SELECT idx, length, string ~ 'html', string FROM line; Result: idxlength?column?string1 257 f with t(x) as (values( XMLPARSE(DOCUMENT ('<root><NotificationServiceDetails NotificationNo="0" AlarmCode="mail" AlarmStartTime="10:00:00" AlarmTime="0" Id ="2" ><NotificationServiceDetail Id="2"><Title><![CDATA[aaaaaaaaaaaaa]]></Title><ContentJson><![CDATA[ 2 22 t <html lang="en"> 3 12 f <head> 4 33 f <meta charset="utf-8"/> 5 20 f more stuff 6 20 f more stuff 716f </table> ... ... snipped for brevity ... 16 rows OK, grand, now I wish to perform a RECURSIVE CTE on it. So, I start by trying something (I thought was) very simple. Obviously, I plan to do more, but I wanted to get the "mechanics" correct to start with. So, my query is: WITH RECURSIVE cte1 (n, ln) AS ( SELECT 1 AS n, string FROM line UNION ALL SELECT n + 1, ln FROM cte1 WHERE n < (SELECT COUNT(*) FROM line) ) SELECT * FROM cte1; i.e. have a counter variable and a string from the line table But, then to my horror, the result of this query is 1with t(x) as (values( XMLPARSE(DOCUMENT ('<root><NotificationServiceDetails NotificationNo="0" AlarmCode="mail" AlarmStartTime="10:00:00" AlarmTime="0" Id ="2" ><NotificationServiceDetail Id="2"><Title><![CDATA[aaaaaaaaaaaaa]]></Title><ContentJson><