Switch Statement from Hell
-
Nothing horrible like using enums or flags as case values, no, we preserve the whole JOIN clause, as issued from some vile marriage between combo box and literals. Yes, the strSQLJOIN value is chosen as a SelectedValue of a combo! There are eight cases, this being the last. The first only includes Level1.
switch (strSQLJOIN) {
.
.
case "LEFT JOIN Extensions ON CallRecords.Ext_ID = Extensions.Ext_ID LEFT JOIN Level1 ON Extensions.LevUp_ID = Level1.Lev_ID LEFT JOIN Level2 ON Level1.LevUp_ID = Level2.Lev_ID LEFT JOIN Level3 ON Level2.LevUp_ID = Level3.Lev_ID LEFT JOIN Level4 ON Level3.LevUp_ID = Level4.Lev_ID LEFT JOIN Level5 ON Level4.LevUp_ID = Level5.Lev_ID LEFT JOIN Level6 ON Level5.LevUp_ID = Level6.Lev_ID LEFT JOIN Level7 ON Level6.LevUp_ID = Level7.Lev_ID LEFT JOIN Level8 ON Level7.LevUp_ID = Level8.Lev_ID LEFT JOIN CAT ON CallRecords.Cat_ID = CAT.Cat_ID ":
detailSelectList = "select Sites.SiteName, Sites.ReportCentre, Level8.LevelCode, Level8.LevelName, ";
strSQLGROUPandORDER = "GROUP BY Sites.SiteName, Sites.ReportCentre, Level8.LevelCode, Level8.LevelName ORDER BY Sites.SiteName, Sites.ReportCentre, Level8.LevelCode, Level8.LevelName;";
break;Well, that is what you can get when applying the principles of self-documenting code. :)
Luc Pattyn [Forum Guidelines] [My Articles]
Avoiding unwanted divs (as in "articles needing approval") with the help of this FireFox add-in
-
Nothing horrible like using enums or flags as case values, no, we preserve the whole JOIN clause, as issued from some vile marriage between combo box and literals. Yes, the strSQLJOIN value is chosen as a SelectedValue of a combo! There are eight cases, this being the last. The first only includes Level1.
switch (strSQLJOIN) {
.
.
case "LEFT JOIN Extensions ON CallRecords.Ext_ID = Extensions.Ext_ID LEFT JOIN Level1 ON Extensions.LevUp_ID = Level1.Lev_ID LEFT JOIN Level2 ON Level1.LevUp_ID = Level2.Lev_ID LEFT JOIN Level3 ON Level2.LevUp_ID = Level3.Lev_ID LEFT JOIN Level4 ON Level3.LevUp_ID = Level4.Lev_ID LEFT JOIN Level5 ON Level4.LevUp_ID = Level5.Lev_ID LEFT JOIN Level6 ON Level5.LevUp_ID = Level6.Lev_ID LEFT JOIN Level7 ON Level6.LevUp_ID = Level7.Lev_ID LEFT JOIN Level8 ON Level7.LevUp_ID = Level8.Lev_ID LEFT JOIN CAT ON CallRecords.Cat_ID = CAT.Cat_ID ":
detailSelectList = "select Sites.SiteName, Sites.ReportCentre, Level8.LevelCode, Level8.LevelName, ";
strSQLGROUPandORDER = "GROUP BY Sites.SiteName, Sites.ReportCentre, Level8.LevelCode, Level8.LevelName ORDER BY Sites.SiteName, Sites.ReportCentre, Level8.LevelCode, Level8.LevelName;";
break;*Attempted to write a reply but got a heart attack while having a second look at the code* Cheers :) BN
GSoC 2009 student for SMW! --- My little forums: http://code.bn2vs.com --- 70 72 6F 67 72 61 6D 6D 69 6E 67 20 34 20 6C 69 66 65!
-
Nothing horrible like using enums or flags as case values, no, we preserve the whole JOIN clause, as issued from some vile marriage between combo box and literals. Yes, the strSQLJOIN value is chosen as a SelectedValue of a combo! There are eight cases, this being the last. The first only includes Level1.
switch (strSQLJOIN) {
.
.
case "LEFT JOIN Extensions ON CallRecords.Ext_ID = Extensions.Ext_ID LEFT JOIN Level1 ON Extensions.LevUp_ID = Level1.Lev_ID LEFT JOIN Level2 ON Level1.LevUp_ID = Level2.Lev_ID LEFT JOIN Level3 ON Level2.LevUp_ID = Level3.Lev_ID LEFT JOIN Level4 ON Level3.LevUp_ID = Level4.Lev_ID LEFT JOIN Level5 ON Level4.LevUp_ID = Level5.Lev_ID LEFT JOIN Level6 ON Level5.LevUp_ID = Level6.Lev_ID LEFT JOIN Level7 ON Level6.LevUp_ID = Level7.Lev_ID LEFT JOIN Level8 ON Level7.LevUp_ID = Level8.Lev_ID LEFT JOIN CAT ON CallRecords.Cat_ID = CAT.Cat_ID ":
detailSelectList = "select Sites.SiteName, Sites.ReportCentre, Level8.LevelCode, Level8.LevelName, ";
strSQLGROUPandORDER = "GROUP BY Sites.SiteName, Sites.ReportCentre, Level8.LevelCode, Level8.LevelName ORDER BY Sites.SiteName, Sites.ReportCentre, Level8.LevelCode, Level8.LevelName;";
break; -
Nothing horrible like using enums or flags as case values, no, we preserve the whole JOIN clause, as issued from some vile marriage between combo box and literals. Yes, the strSQLJOIN value is chosen as a SelectedValue of a combo! There are eight cases, this being the last. The first only includes Level1.
switch (strSQLJOIN) {
.
.
case "LEFT JOIN Extensions ON CallRecords.Ext_ID = Extensions.Ext_ID LEFT JOIN Level1 ON Extensions.LevUp_ID = Level1.Lev_ID LEFT JOIN Level2 ON Level1.LevUp_ID = Level2.Lev_ID LEFT JOIN Level3 ON Level2.LevUp_ID = Level3.Lev_ID LEFT JOIN Level4 ON Level3.LevUp_ID = Level4.Lev_ID LEFT JOIN Level5 ON Level4.LevUp_ID = Level5.Lev_ID LEFT JOIN Level6 ON Level5.LevUp_ID = Level6.Lev_ID LEFT JOIN Level7 ON Level6.LevUp_ID = Level7.Lev_ID LEFT JOIN Level8 ON Level7.LevUp_ID = Level8.Lev_ID LEFT JOIN CAT ON CallRecords.Cat_ID = CAT.Cat_ID ":
detailSelectList = "select Sites.SiteName, Sites.ReportCentre, Level8.LevelCode, Level8.LevelName, ";
strSQLGROUPandORDER = "GROUP BY Sites.SiteName, Sites.ReportCentre, Level8.LevelCode, Level8.LevelName ORDER BY Sites.SiteName, Sites.ReportCentre, Level8.LevelCode, Level8.LevelName;";
break;Thank God! There are only 8 levels!!
"Don't worry if it doesn't work right. If everything did, you'd be out of a job." (Mosher's Law of Software Engineering)
-
Nothing horrible like using enums or flags as case values, no, we preserve the whole JOIN clause, as issued from some vile marriage between combo box and literals. Yes, the strSQLJOIN value is chosen as a SelectedValue of a combo! There are eight cases, this being the last. The first only includes Level1.
switch (strSQLJOIN) {
.
.
case "LEFT JOIN Extensions ON CallRecords.Ext_ID = Extensions.Ext_ID LEFT JOIN Level1 ON Extensions.LevUp_ID = Level1.Lev_ID LEFT JOIN Level2 ON Level1.LevUp_ID = Level2.Lev_ID LEFT JOIN Level3 ON Level2.LevUp_ID = Level3.Lev_ID LEFT JOIN Level4 ON Level3.LevUp_ID = Level4.Lev_ID LEFT JOIN Level5 ON Level4.LevUp_ID = Level5.Lev_ID LEFT JOIN Level6 ON Level5.LevUp_ID = Level6.Lev_ID LEFT JOIN Level7 ON Level6.LevUp_ID = Level7.Lev_ID LEFT JOIN Level8 ON Level7.LevUp_ID = Level8.Lev_ID LEFT JOIN CAT ON CallRecords.Cat_ID = CAT.Cat_ID ":
detailSelectList = "select Sites.SiteName, Sites.ReportCentre, Level8.LevelCode, Level8.LevelName, ";
strSQLGROUPandORDER = "GROUP BY Sites.SiteName, Sites.ReportCentre, Level8.LevelCode, Level8.LevelName ORDER BY Sites.SiteName, Sites.ReportCentre, Level8.LevelCode, Level8.LevelName;";
break;What about the other case statements? I'm curious now!! ;)
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station.... _________________________________________________________ My programs never have bugs, they just develop random features.
-
What about the other case statements? I'm curious now!! ;)
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station.... _________________________________________________________ My programs never have bugs, they just develop random features.
OK, that was the last one, here are the first two.. You should be able to infer the rest.
case "LEFT JOIN Extensions ON CallRecords.Ext\_ID = Extensions.Ext\_ID LEFT JOIN Level1 ON Extensions.LevUp\_ID = Level1.Lev\_ID LEFT JOIN CAT ON CallRecords.Cat\_ID = CAT.Cat\_ID ": strSQL = strSQL + "Sites.SiteName, Sites.ReportCentre, Level1.LevelCode, Level1.LevelName, "; strSQLGROUPandORDER = "GROUP BY Sites.SiteName, Sites.ReportCentre, Level1.LevelCode, Level1.LevelName ORDER BY Sites.SiteName, Sites.ReportCentre, Level1.LevelCode, Level1.LevelName;"; break; case "LEFT JOIN Extensions ON CallRecords.Ext\_ID = Extensions.Ext\_ID LEFT JOIN Level1 ON Extensions.LevUp\_ID = Level1.Lev\_ID LEFT JOIN Level2 ON Level1.LevUp\_ID = Level2.Lev\_ID LEFT JOIN CAT ON CallRecords.Cat\_ID = CAT.Cat\_ID ": strSQL = strSQL + "Sites.SiteName, Sites.ReportCentre, Level2.LevelCode, Level2.LevelName, "; strSQLGROUPandORDER = "GROUP BY Sites.SiteName, Sites.ReportCentre, Level2.LevelCode, Level2.LevelName ORDER BY Sites.SiteName, Sites.ReportCentre, Level2.LevelCode, Level2.LevelName;"; break;
You really gotta try harder to keep up with everyone that's not on the short bus with you. - John Simmons / outlaw programmer.
-
OK, that was the last one, here are the first two.. You should be able to infer the rest.
case "LEFT JOIN Extensions ON CallRecords.Ext\_ID = Extensions.Ext\_ID LEFT JOIN Level1 ON Extensions.LevUp\_ID = Level1.Lev\_ID LEFT JOIN CAT ON CallRecords.Cat\_ID = CAT.Cat\_ID ": strSQL = strSQL + "Sites.SiteName, Sites.ReportCentre, Level1.LevelCode, Level1.LevelName, "; strSQLGROUPandORDER = "GROUP BY Sites.SiteName, Sites.ReportCentre, Level1.LevelCode, Level1.LevelName ORDER BY Sites.SiteName, Sites.ReportCentre, Level1.LevelCode, Level1.LevelName;"; break; case "LEFT JOIN Extensions ON CallRecords.Ext\_ID = Extensions.Ext\_ID LEFT JOIN Level1 ON Extensions.LevUp\_ID = Level1.Lev\_ID LEFT JOIN Level2 ON Level1.LevUp\_ID = Level2.Lev\_ID LEFT JOIN CAT ON CallRecords.Cat\_ID = CAT.Cat\_ID ": strSQL = strSQL + "Sites.SiteName, Sites.ReportCentre, Level2.LevelCode, Level2.LevelName, "; strSQLGROUPandORDER = "GROUP BY Sites.SiteName, Sites.ReportCentre, Level2.LevelCode, Level2.LevelName ORDER BY Sites.SiteName, Sites.ReportCentre, Level2.LevelCode, Level2.LevelName;"; break;
You really gotta try harder to keep up with everyone that's not on the short bus with you. - John Simmons / outlaw programmer.
I see, mmm... Really the original programmer should have foreseen the problem and use Emit to dynamically generate/compile a method for an ever increasing number of case! :cool: :laugh:
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station.... _________________________________________________________ My programs never have bugs, they just develop random features.
-
I see, mmm... Really the original programmer should have foreseen the problem and use Emit to dynamically generate/compile a method for an ever increasing number of case! :cool: :laugh:
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station.... _________________________________________________________ My programs never have bugs, they just develop random features.
Super Lloyd wrote:
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
:laugh: :laugh: :laugh: I want to steal your signature!
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced. This message is made of fully recyclable Zeros and Ones
-
Super Lloyd wrote:
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
:laugh: :laugh: :laugh: I want to steal your signature!
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced. This message is made of fully recyclable Zeros and Ones
Ho no... I already stole it from someone else, you can't steal it from me!!! :rolleyes:
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station.... _________________________________________________________ My programs never have bugs, they just develop random features.
-
*Attempted to write a reply but got a heart attack while having a second look at the code* Cheers :) BN
GSoC 2009 student for SMW! --- My little forums: http://code.bn2vs.com --- 70 72 6F 67 72 61 6D 6D 69 6E 67 20 34 20 6C 69 66 65!