Skip to content

Commit b371064

Browse files
committed
Update Patterns RCTEs Modify.md
1 parent acf7497 commit b371064

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

Patterns RCTEs Modify.md

+14-14
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ Recursive CTEs enable the implementation of the following task. Suppose we have
1010

1111
~~~sql
1212
WITH RECURSIVE
13+
ops(opid, rootpath_old, rootpath_new) AS (
14+
VALUES
15+
(1, 'doc/', 'docABC' ),
16+
(2, 'docABC/thesis/', 'docABC/master' ),
17+
(3, 'docABC/app/job/', 'docABC/app/academic_job'),
18+
(4, 'code/', 'prog' )
19+
),
1320
folders(path_old) AS (
1421
VALUES
1522
('doc/thesis/exp'),
@@ -18,13 +25,6 @@ WITH RECURSIVE
1825
('code/scripts/py'),
1926
('code/scripts/bas')
2027
),
21-
ops(opid, rootpath_old, rootpath_new) AS (
22-
VALUES
23-
(1, 'doc/', 'docABC' ),
24-
(2, 'docABC/thesis/', 'docABC/master' ),
25-
(3, 'docABC/app/job/', 'docABC/app/academic_job'),
26-
(4, 'code/', 'prog' )
27-
),
2828
LOOP_COPY AS (
2929
-- Initial SELECT --
3030
SELECT 0 AS opid, path_old AS path_new
@@ -52,6 +52,13 @@ Even though the RCTE loop body processes one row at a time, when the processing
5252

5353
~~~sql
5454
WITH RECURSIVE
55+
ops(opid, rootpath_old, rootpath_new) AS (
56+
VALUES
57+
(1, 'doc/', 'docABC' ),
58+
(2, 'docABC/thesis/', 'docABC/master' ),
59+
(3, 'docABC/app/job/', 'docABC/app/academic_job'),
60+
(4, 'code/', 'prog' )
61+
),
5562
folders(path_old) AS (
5663
VALUES
5764
('doc/thesis/exp'),
@@ -60,13 +67,6 @@ WITH RECURSIVE
6067
('code/scripts/py'),
6168
('code/scripts/bas')
6269
),
63-
ops(opid, rootpath_old, rootpath_new) AS (
64-
VALUES
65-
(1, 'doc/', 'docABC' ),
66-
(2, 'docABC/thesis/', 'docABC/master' ),
67-
(3, 'docABC/app/job/', 'docABC/app/academic_job'),
68-
(4, 'code/', 'prog' )
69-
),
7070
LOOP_COPY_INIT AS (
7171
SELECT 0 AS opid, path_old AS path_new
7272
FROM folders

0 commit comments

Comments
 (0)