Skip to content

Commit

Permalink
Merge pull request #207 from HuangSongZ/master
Browse files Browse the repository at this point in the history
fix: CONNECT_BY_ROOT in hierarchical query is converted to WITH RECURSIVE syntax
  • Loading branch information
okbob authored Jan 12, 2023
2 parents 33cea9c + c12abf3 commit 76d8366
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions doc/sql_migration/sql_migration04.md
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,7 @@ In a recursive query that uses a WITH clause, add a root column that also uses t
2. Add root column to the column list of the query result of the WITH clause.

- In the first query, specify the root columnName to the values of the columns from the root to the node.
- Specify m.columnName in the next query. (columnName is a root column.)
- Specify m.rootName in the next query. (rootName is a root column.)


The following shows the conversion format containing rootName.
Expand All @@ -817,7 +817,7 @@ WITH RECURSIVE queryName(
( SELECT columnUsed, columnName
FROM targetTableOfHierarchicalQuery
UNION ALL
SELECT columnUsed(qualified by n), w.columnName
SELECT columnUsed(qualified by n), w.rootName
FROM targetTableOfHierarchicalQuery n,
queryName w
WHERE conditionalExprOfConnectByClause )
Expand Down Expand Up @@ -856,12 +856,13 @@ The example below shows migration when the root data is displayed.
<pre><code>WITH RECURSIVE staff_table_w( staff_id,
name,
Manager ) AS
( SELECT staff_id, name, <b>name </b>
( SELECT staff_id, name, <b>name </b>
FROM staff_table
UNION ALL
SELECT n.staff_id, n.name, <b>w.name </b>
SELECT n.staff_id, n.name, <b>w.Manager </b>
FROM staff_table n, staff_table_w w
WHERE w.staff_id = n.manager_id )
WHERE w.staff_id = n.manager_id
)
SELECT staff_id, name, Manager
FROM staff_table_w;</code></pre>
</td>
Expand Down

0 comments on commit 76d8366

Please sign in to comment.