If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > SQL Recursion Parent/Child

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-13-12, 07:56
dlg63 dlg63 is offline
Registered User
 
Join Date: Aug 2012
Posts: 1
SQL Recursion Parent/Child

I am new to IBM DB2 (1 month)

Here is my situation:

I have the following query:

SELECT nmnm.MSMS_PTPTP_NONO_ID, MSMS_PTPTP_NM, PRPR_PTPTP_NONO_ID
FROM PRTPR.N_MSMS_PRPR_TXTX nmnm
LEFT JOIN PRTPR.MSMS_PRPR_TXTX ON nmnm.MSMS_PTXPT_NONO_ID = PRTPR.MSMS_PRPR_TXT.MSMS_PTXPT_NONO_ID

1002|ccccccc|1001

1001|dddddddd|x2218

PRNT_PTXMY_NODE_ID it the parent and needs to look for the value in MSTR_PTXMY_NODE_ID and that value PRNT_PTXMY_NODE_ID needs to look in MSTR_PTXMY_NODE_ID -- Recursion

Example:
\pppppp\dddddddd\ccccccc\pp - etc...

I tried using the CONNECT_BY_ROOT but was unsuccessful


Any help would be gratefully appreciated.

David
Reply With Quote
  #2 (permalink)  
Old 08-13-12, 08:02
przytula_guy przytula_guy is offline
Registered User
 
Join Date: Apr 2006
Location: Belgium
Posts: 1,755
is there a problem with CONNECT_BY_ROOT or with your query you don't display
os ?? db2level ?? db2 platform??
try to read the entry in this forum : how to submit a question ....and what todo before submitting a question....
finally check the doc .. there must be some samples..
search in this forum.. the sql special-x : Mr Tonkuma submitted many samples on this..
__________________
Best Regards, Guy Przytula
Database Software Consultant
DB2 UDB LUW Certified V7-V8-V9-V9.7-V10 DB Admin - Dprop..
Information Server Datastage Certified
http://www.infocura.be
Reply With Quote
  #3 (permalink)  
Old 08-14-12, 04:12
Peter.Vanroose Peter.Vanroose is offline
Registered User
 
Join Date: Sep 2004
Location: Belgium
Posts: 1,126
Quote:
Originally Posted by dlg63 View Post
I tried using the CONNECT_BY_ROOT but was unsuccessful
CONNECT_BY_ROOT is an Oracle nonstandard SQL extension; DB2 uses the standard RECURSIVE construct with a common table expression; search for "recursive" in earlier threads in this forum for examples, or have a look in the DB2 SQL Reference Guide (e.g. in Chapter 5, Select Statement, Common Table Expression, Recursion Example: bill of materials).
__________________
--_Peter Vanroose,
__IBM Certified Database Administrator, DB2 9 for z/OS
__IBM Certified Application Developer
__ABIS Training and Consulting
__http://www.abis.be/
Reply With Quote
  #4 (permalink)  
Old 08-14-12, 07:28
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 5,054
Quote:
Originally Posted by Peter.Vanroose View Post
CONNECT_BY_ROOT is an Oracle nonstandard SQL extension;
Since version 9.7 DB2 LUW has an Oracle compatibility mode, whereas it supports or tolerates a number of Oracle proprietary SQL constructs, including the CONNECT BY syntax for recursive queries and the CONNECT_BY_ROOT function.
__________________
---
"It does not work" is not a valid problem statement.
Reply With Quote
Reply

Tags
node, parent, recursion, sql

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On