Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Classic ASP Professional For advanced coder questions in ASP 3. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Professional section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 8th, 2007, 11:15 PM
Friend of Wrox
Points: 686, Level: 9
Points: 686, Level: 9 Points: 686, Level: 9 Points: 686, Level: 9
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2005
Location: Kolkata, West Bengal, India.
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
Default Recursive Coding

Hi All,

I need help on coding a recursive loop for searching values from the database. My requirement is that I am sending the parent Product Id & Name as parameters to a function which is using these parameters in SQL Search query to find Sub-Products under the Parent Product Id & Name. This function will be called repeatedly so that I can find all the sub-products till the 'nth' level until there are no sub-products left. Each time the function will return the Product id & Name for the sub-product which will be used to call the function again.


Any help on this would be gr8 !!!
Reply With Quote
  #2 (permalink)  
Old July 9th, 2007, 01:53 AM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

Im not so sure you need a recursive function for this. I do this all the time using SQL joins. Cant you get the records in one query? If not, why not?

I read your post again thinking I mis-read it. If you do things the way you are suggesting there are going to be alot of queries being executed. IMO, to many.

Wind is your friend
Matt
Reply With Quote
  #3 (permalink)  
Old July 9th, 2007, 02:06 AM
Friend of Wrox
Points: 686, Level: 9
Points: 686, Level: 9 Points: 686, Level: 9 Points: 686, Level: 9
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2005
Location: Kolkata, West Bengal, India.
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Can you help me on the join query ?

presently I am using the following queries:
select Distinct ID,PartNum,PName
from Product,TRLNK246
where
Product.ID in (select Object2 from TRLNK246 where Product= 1) and Product.Status = 'Active'

select Distinct ID,PartNum,PName
from Product,TRLNK246
where
Product.ID in (select Object2 from TRLNK246 where Product= 17) and Product.Status = 'Active'

select Distinct ID,PartNum,PName
from Product,TRLNK246
where
Product.ID in (select Object2 from TRLNK246 where Product= 11) and Product.Status = 'Active'

---------------------------
Here in this case :
Product Object2
1 15
1 16
1 17
17 11
17 12
17 13
11 5
11 6
11 7
---------------------
The above structure is for the Link table TRLNK246 which is a child table of the main Product Table cantaining the distinct Product IDs.

I am fetching the child table products contained in Object2 related to the main Products in Field Product.

I basically thought of a recursive function which will generate the sub-products.
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 Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with a recursive Query!!! dbayona SQL Server 2005 1 December 20th, 2007 07:40 AM
Recursive template - Please Help! Tre XSLT 5 March 20th, 2007 11:23 AM
recursive query cathiec SQL Language 2 August 25th, 2006 05:58 AM
recursive XSLT Help boates XSLT 2 January 11th, 2006 03:50 PM
Recursive Transform chuck.boyer XSLT 0 December 5th, 2005 05:51 PM



All times are GMT -4. The time now is 08:59 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.