Dear Barry, I'll second Greg's idea. One link I think might help you is Peter Brawley's and Arthur Fuller's excellent tutorial "Trees and Other Hierarchies in MySQL" http://www.artfulsoftware.com/mysqlbook/sampler/mysqled1ch20.html. This is of course MySQL, not Oracle (which BTW now owns MySQL), but these two are close enough.
I would be happy to hear about your solution(s) Meir -----Original Message----- From: perl-win32-users-boun...@listserv.activestate.com [mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of Greg Aiken Sent: Monday, March 07, 2011 6:07 PM To: bbre...@stellarmicro.com; perl-win32-users@listserv.ActiveState.com Subject: RE: Help with Array of Arrays if you are not in control of the base sql query, then disregard this comment... however if you are in control of the sql query that executes to oracle, you might want to see how oracles 'connect by' function might be able to help you handle the hierarchical nature of the relationship. perhaps a different query can be executed that shifts the burden of dealing with the hierarchical data handling from your code, to the oracle db engine. I'm unsure if this might be able to lighten your load, or not, but check it out. I'm not a current oracle user, but years ago I tinkered with it, and I remember how 'connect by' proved to be a helpful friend. -----Original Message----- From: perl-win32-users-boun...@listserv.activestate.com [mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of Barry Brevik Sent: Sunday, March 06, 2011 4:05 PM To: perl-win32-users@listserv.ActiveState.com Subject: Help with Array of Arrays I always get majorly confused when I have to deal with Arrays of Arrays, Arrays of Hashes etc. The Camel book has a good section on this, but it is not always enough. That's why each time I do one, I document it in a file on my disk. However, I have not done this one before. I am extracting Bill of Material (BOM) data from our Oracle system. In my case, each BOM has any number of line items (array) and each line has 5 data items that I am working with (array of arrays). However, any line item can be a "part" that is itself another BOM, so I end up with a sort of tree structure. As I enumerate each line on the TOP LEVEL BOM, when I come to another BOM, I have to stop what I'm doing, "save my place" (yet another array of arrays), and go down into this next BOM. To save my place, I have an array named "stack" upon which I push the entire BOM currently being enumerated, along with several scalars that have to do with what line item I stopped at and so on. The code below demonstrates exactly what I'm doing. The code works, so I'm OK there, but I can't get over the feeling that there is a better way to implement my stack. If anybody has any advice, I'm all ears. ============================= use strict; use warnings; my $i = 2; my $curlvl = 0; my @stack = (); my @thisBOM = ( ["10", "1", "1", "MS51957-59-10", "Screw, Pan HD, 2-56 x .5"], ["20", "2", "1", "MS51957-59-20", "Screw, Pan HD, 4-40 x 1"], ["30", "3", "1", "MS51957-59-30", "Screw, Pan HD, 6-32 x 1.25"] ); # Just print the BOM for reference. print "i.....: $i\n"; print "curlvl: $curlvl\n"; for my $i (0..$#thisBOM) { print "$i: @{$thisBOM[$i]}\n"; } print "\n\n\n"; # Save our place. push @stack, [($i, $curlvl, [@thisBOM])]; # re-init the variables. $i = $curlvl = ''; @thisBOM = (); # Now, recover where we left off. ($i, $curlvl, @thisBOM) = @{pop @stack}; @thisBOM = @{$thisBOM[0]}; # Print the BOM again to make sure it came off the stack the way it went on. print "i.....: $i\n"; print "curlvl: $curlvl\n"; for my $i (0..$#thisBOM) { print "$i: @{$thisBOM[$i]}\n"; } print "\n\n\n"; _______________________________________________ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs _______________________________________________ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs _______________________________________________ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs