The WHILE loop conundrum

In case it's not obvious, I am hardly a master programmer.  So when it came to this admittedly common bit of programming logic, I was stumped.

I am trying to put together a Board of Directors list for my executive director that includes the usual information.  But in addition to that it has been requested that I include all relevant associations for each member.  This is a classic situation where I either need to have a variable number of columns (depending on the number of associations any one member may have) or some method of concatenating each separate association in a single column.

I assume this is accomplished with some kind of WHILE loop, but I missed that day in programming class.  Anyone willing to help me out?

BONUS TRIVIA SNACK: There is the same number of chickens in the world as humans.

Parents
  • A few things pop to mind.  If all you need is a report, you might want to look at the stock "Full Bio Report" in the Development folder.  It lists Associations along with almost everything else under the sun. Even if you can't use it, it is a good jumping off point for seeing how you might structure sub reports.

    From a purely programming standpoint, I don't think the WHILE loop is what you are looking for.  A feature introduced in SQL 2005 that might (and I stress MIGHT) be useful is PIVOT (a brief tutorial: http://geekswithblogs.net/lorint/archive/2006/08/04/87166.aspx).  PIVOT essentially allows you to do in a query what Excel does with a pivot table.  The practical upshot is that you have a query that returns columns dynamically.  The downside is there is a lot of tedious scripting to get to that point.

    Concatenating sounds like a cleaner way to approach it provided you don't need to sort or otherwise manage the associations beyond displaying them.  A good example would be to look at FS_CONST_STRING under Functions>Scalar-valued Functions.  It does with constituentcies what I think you want to do with associations.

Reply
  • A few things pop to mind.  If all you need is a report, you might want to look at the stock "Full Bio Report" in the Development folder.  It lists Associations along with almost everything else under the sun. Even if you can't use it, it is a good jumping off point for seeing how you might structure sub reports.

    From a purely programming standpoint, I don't think the WHILE loop is what you are looking for.  A feature introduced in SQL 2005 that might (and I stress MIGHT) be useful is PIVOT (a brief tutorial: http://geekswithblogs.net/lorint/archive/2006/08/04/87166.aspx).  PIVOT essentially allows you to do in a query what Excel does with a pivot table.  The practical upshot is that you have a query that returns columns dynamically.  The downside is there is a lot of tedious scripting to get to that point.

    Concatenating sounds like a cleaner way to approach it provided you don't need to sort or otherwise manage the associations beyond displaying them.  A good example would be to look at FS_CONST_STRING under Functions>Scalar-valued Functions.  It does with constituentcies what I think you want to do with associations.

Children
No Data