Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Recursive lookup of all job numbers.
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00871246
Message ID:
00871259
Vues:
14
Douglas,
create cursor jobs ( jobno i, subjobno i )

insert into jobs values ( 1, 2 )
insert into jobs values ( 1, 3 )
insert into jobs values ( 1, 4 )
insert into jobs values ( 1, 5 )
insert into jobs values ( 1, 6 )

insert into jobs values ( 2, 7 )
insert into jobs values ( 2, 8 )
insert into jobs values ( 2, 9 )
insert into jobs values ( 2, 10 )
insert into jobs values ( 2, 11 )

insert into jobs values ( 7, 12 )
insert into jobs values ( 7, 13 )
insert into jobs values ( 7, 14 )
insert into jobs values ( 7, 15 )
insert into jobs values ( 7, 16 )

insert into jobs values ( 12, 17 )
insert into jobs values ( 12, 18 )

insert into jobs values ( 16, 22 )

insert into jobs values ( 19, 20 )

insert into jobs values ( 20, 21 )


create cursor jobstodo ( jobno i )

set step on
FindSubJobsOf( 1 )
FindSubJobsOf( 20 )

* the jobstodo cursor now has a list of jobs and their subjobs

function FindSubJobsOf( lnJobNo )

insert into jobstodo values ( lnJobNo )

local lcCursorName

lcCursorName = "thisjob" + transform( lnJobNo )

select subjobno as jobno ;
   from jobs ;
   into cursor (lcCursorName) ;
   where jobno = lnJobNo

if ( _tally > 0 )
   select (lcCursorName)
   scan
      FindSubJobsOf( jobno )
   endscan
endif

use in (lcCursorName)
return
>Does anyone have any sample code of parameter passing for doing recursion on data in tables. I'm not sure the best way to solve this issue, but here is what is needed. Given a starting list of n job numbers we need to find all the unique Job#'s that could be sub-assemblies of the starting n jobs. They are in a 2 field tbl (fields: job, subjob). I'm thinking it needs to work recursively but I'm not sure the best way to drill down for all n Job#'s and to make sure that if there are multiple entries in tbl for some of the n jobs or even some of the subjobs, that we pick up all job#'s.
>
>Any thoughts?
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform