0
有些帖子說PostgreSQL的CTE基本上是迭代的,我不知道如何使用尾遞歸和plpgsql語言編寫查詢?如何使用Plpgsql語言編寫尾遞歸?
有些帖子說PostgreSQL的CTE基本上是迭代的,我不知道如何使用尾遞歸和plpgsql語言編寫查詢?如何使用Plpgsql語言編寫尾遞歸?
WITH RECURSIVE zzz AS (
SELECT 11::integer AS val
UNION ALL
SELECT CASE WHEN (zzz.val %2 = 1) THEN 3*zzz.val+1 ELSE zzz.val/2 END AS val
FROM zzz
WHERE zzz.val <> 1
)
SELECT * FROM zzz;