Skip to content

Commit 0f2f5da

Browse files
committed
Update Patterns Recursive CTEs.md
1 parent 8995e17 commit 0f2f5da

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

Patterns Recursive CTEs.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -89,32 +89,32 @@ Even though the RCTE loop body processes one row at a time, when the processing
8989

9090
~~~sql
9191
WITH RECURSIVE
92-
folders(path_old) AS (
93-
VALUES
94-
('doc/thesis/exp'),
95-
('doc/thesis/theory'),
96-
('doc/app/job/lor'),
97-
('code/scripts/py'),
98-
('code/scripts/bas')
99-
),
92+
folders(path_old) AS (
93+
VALUES
94+
('doc/thesis/exp'),
95+
('doc/thesis/theory'),
96+
('doc/app/job/lor'),
97+
('code/scripts/py'),
98+
('code/scripts/bas')
99+
),
100100
ops(opid, rootpath_old, rootpath_new) AS (
101101
VALUES
102-
(1, 'doc/', 'docABC' ),
103-
(2, 'docABC/thesis/', 'docABC/master' ),
104-
(3, 'docABC/app/job/', 'docABC/app/academic_job'),
105-
(4, 'code/', 'prog' )
102+
(1, 'doc/', 'docABC' ),
103+
(2, 'docABC/thesis/', 'docABC/master' ),
104+
(3, 'docABC/app/job/', 'docABC/app/academic_job'),
105+
(4, 'code/', 'prog' )
106106
),
107107
LOOP_COPY_INIT AS (
108-
SELECT 0 AS opid, path_old AS path_new
109-
FROM folders
108+
SELECT 0 AS opid, path_old AS path_new
109+
FROM folders
110110
),
111111
LOOP_COPY_STEP_1 AS (
112112
SELECT ops.opid, path_new
113113
FROM LOOP_COPY_INIT AS BUFFER, ops
114114
WHERE ops.opid = BUFFER.opid + 1
115115
UNION ALL
116116
SELECT ops.opid,
117-
rootpath_new || substr(path_new, length(rootpath_old)) AS path_new
117+
rootpath_new || substr(path_new, length(rootpath_old)) AS path_new
118118
FROM LOOP_COPY_INIT AS BUFFER, ops
119119
WHERE ops.opid = BUFFER.opid + 1
120120
AND BUFFER.path_new like rootpath_old || '%'
@@ -125,7 +125,7 @@ WITH RECURSIVE
125125
WHERE ops.opid = BUFFER.opid + 1
126126
UNION ALL
127127
SELECT ops.opid,
128-
rootpath_new || substr(path_new, length(rootpath_old)) AS path_new
128+
rootpath_new || substr(path_new, length(rootpath_old)) AS path_new
129129
FROM LOOP_COPY_STEP_1 AS BUFFER, ops
130130
WHERE ops.opid = BUFFER.opid + 1
131131
AND BUFFER.path_new like rootpath_old || '%'
@@ -136,7 +136,7 @@ WITH RECURSIVE
136136
WHERE ops.opid = BUFFER.opid + 1
137137
UNION ALL
138138
SELECT ops.opid,
139-
rootpath_new || substr(path_new, length(rootpath_old)) AS path_new
139+
rootpath_new || substr(path_new, length(rootpath_old)) AS path_new
140140
FROM LOOP_COPY_STEP_2 AS BUFFER, ops
141141
WHERE ops.opid = BUFFER.opid + 1
142142
AND BUFFER.path_new like rootpath_old || '%'
@@ -147,7 +147,7 @@ WITH RECURSIVE
147147
WHERE ops.opid = BUFFER.opid + 1
148148
UNION ALL
149149
SELECT ops.opid,
150-
rootpath_new || substr(path_new, length(rootpath_old)) AS path_new
150+
rootpath_new || substr(path_new, length(rootpath_old)) AS path_new
151151
FROM LOOP_COPY_STEP_3 AS BUFFER, ops
152152
WHERE ops.opid = BUFFER.opid + 1
153153
AND BUFFER.path_new like rootpath_old || '%'
@@ -158,7 +158,7 @@ WITH RECURSIVE
158158
WHERE ops.opid = BUFFER.opid + 1
159159
UNION ALL
160160
SELECT ops.opid,
161-
rootpath_new || substr(path_new, length(rootpath_old)) AS path_new
161+
rootpath_new || substr(path_new, length(rootpath_old)) AS path_new
162162
FROM LOOP_COPY_STEP_4 AS BUFFER, ops
163163
WHERE ops.opid = BUFFER.opid + 1
164164
AND BUFFER.path_new like rootpath_old || '%'

0 commit comments

Comments
 (0)