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 > Recursive SQL DB2/AS400

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-16-04, 09:12
ReinhardN ReinhardN is offline
Registered User
 
Join Date: Jul 2004
Posts: 2
Unhappy Recursive SQL DB2/AS400

Hi,

I have problems with this sql statement.


Table = emaila01
colum
evname enname
AAA--------BBB
AAA--------CCC
AAA--------DDD
CCC--------EEE
DDD--------FFF


sqlstring3 = "with temp (enname) as " _
& "(select distinct evname " _
& "from emaila01 " _
& "where evname = 'AAA' " _
& "union all " _
& "select c.enname" _
& "from emaila01 c, temp p " _
& "where p.enname = c.evname) " _
& "select distinct enname from temp"


The answer must be

BBB
CCC
DDD
EEE
FFF


What is wrong?

Reinhard

Last edited by ReinhardN; 07-19-04 at 03:52.
Reply With Quote
  #2 (permalink)  
Old 07-16-04, 10:25
J Petruk J Petruk is offline
Registered User
 
Join Date: Mar 2004
Location: Toronto, ON, Canada
Posts: 513
It's an infinite loop, no? You get ('DDD','AAA'), then 'AAA','DDD' which re-matches 'DDD','AAA'... forever.
__________________
--
Jonathan Petruk
DB2 Database Consultant
Reply With Quote
  #3 (permalink)  
Old 07-20-04, 01:08
ReinhardN ReinhardN is offline
Registered User
 
Join Date: Jul 2004
Posts: 2
Hi,

why the DBS/AS400 have not a statement for the recursive sql-select?

In ORACLE SQL I have the "connect by prior" statement.


greetings

ReinhardN
Reply With Quote
Reply

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