Wrox Programmer Forums
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 8th, 2007, 11:15 PM
Friend of Wrox
 
Join Date: Apr 2005
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 !!!
 
Old July 9th, 2007, 01:53 AM
Friend of Wrox
 
Join Date: Jan 2004
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
 
Old July 9th, 2007, 02:06 AM
Friend of Wrox
 
Join Date: Apr 2005
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.





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





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