[thelist] Nested Queries

Joshua Olson joshua at waetech.com
Wed Aug 21 09:50:01 CDT 2002


----- Original Message -----
From: "Feingold Josh S" <Josh.S.Feingold at irs.gov>
Sent: Wednesday, August 21, 2002 10:15 AM


> [ Picked text/plain from multipart/alternative ]
> I have an email application that allows people to send emails to people by
> selecting the group that they want.  Each group can be made up of other
> groups.

Josh,

Watch out.  This one can get really nasty really fast.  The problem can be
solved using a pair of stacks. If you don't know what a stack is, think of
it as a temporary table.  You start by selecting the originally selected
emails an putting those onto one stack.  Any originally selected groups go
onto the other stack.  Then, peal the first group off the top of the group
stack and start over.  Repeat until you have a full stack of emails and an
empty stack of groups.

Sounds simple?

Well, here's where it gets nasty.  Pretend for a moment that a group
contains another group, which contains the first group.  Oh my goodness, it
just became harder.  Unless you're really up for this processing journey, or
can ensure ahead of time that you have no cycles in the data, you may want
to rethink your strategy.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Okay, now to some ASP coding hints:

Use dictionary objects as both stacks.  This way, inserting the same email
or group multiple times will not create redundant records.

- select checked email addresses
- select checked groups

- loop:
   - place selected email addresses into email dictionary object
   - place selected groups into group dictionary object
   - is group dictionary object empty?
     - no, pull one group out of dictionary and select all emails and
sub-groups for that group.  Remove group from dictionary object.
     - yes, jump out of loop
- repeat loop

- send email to everybody in email dictionary object

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Let me know if you need any more help or some actual code.

-joshua




More information about the thelist mailing list