bad SQL case
-
I want to throw my computer off the roof. I'm modifying a 700+ line stored procedure and this is done a dozen+ times.
( CASE WHEN [SomeID] IN ( [batch of hardcoded, unique ids] )
THEN [hardcoded enum]
ELSE ( CASE WHEN [SomeID] IN ( [batch of hardcoded, unique ids] )
THEN [hardcoded enum]
ELSE ( CASE WHEN [SomeID] IN ( [batch of hardcoded, unique ids] )
THEN [hardcoded enum]
ELSE …etc…
END )
END )
END )I …just… :((
-
I want to throw my computer off the roof. I'm modifying a 700+ line stored procedure and this is done a dozen+ times.
( CASE WHEN [SomeID] IN ( [batch of hardcoded, unique ids] )
THEN [hardcoded enum]
ELSE ( CASE WHEN [SomeID] IN ( [batch of hardcoded, unique ids] )
THEN [hardcoded enum]
ELSE ( CASE WHEN [SomeID] IN ( [batch of hardcoded, unique ids] )
THEN [hardcoded enum]
ELSE …etc…
END )
END )
END )I …just… :((
:(( :(( :(( :((
public class SysAdmin : Employee
{public override void DoWork(IWorkItem workItem) { if (workItem.User.Type == UserType.NoLearn){ throw new NoIWillNotFixYourComputerException(new Luser(workItem.User)); }else{ base.DoWork(workItem); } }
}
-
:(( :(( :(( :((
public class SysAdmin : Employee
{public override void DoWork(IWorkItem workItem) { if (workItem.User.Type == UserType.NoLearn){ throw new NoIWillNotFixYourComputerException(new Luser(workItem.User)); }else{ base.DoWork(workItem); } }
}
:laugh: And I’ll probably get confronted for changing it. (I’m the new guy in the group.) I think I’ll adopt a new saying: if you don’t respect my genius then you’ll fear my delete key!
-
:laugh: And I’ll probably get confronted for changing it. (I’m the new guy in the group.) I think I’ll adopt a new saying: if you don’t respect my genius then you’ll fear my delete key!
sorry, i wanted to give you a 5, but clicked on the 4, so.. please, post again so i can give you another 5 ;P
I'm brazilian and english (well, human languages in general) aren't my best skill, so, sorry by my english. (if you want we can speak in C# or VB.Net =p)
-
sorry, i wanted to give you a 5, but clicked on the 4, so.. please, post again so i can give you another 5 ;P
I'm brazilian and english (well, human languages in general) aren't my best skill, so, sorry by my english. (if you want we can speak in C# or VB.Net =p)
no problem
-
I want to throw my computer off the roof. I'm modifying a 700+ line stored procedure and this is done a dozen+ times.
( CASE WHEN [SomeID] IN ( [batch of hardcoded, unique ids] )
THEN [hardcoded enum]
ELSE ( CASE WHEN [SomeID] IN ( [batch of hardcoded, unique ids] )
THEN [hardcoded enum]
ELSE ( CASE WHEN [SomeID] IN ( [batch of hardcoded, unique ids] )
THEN [hardcoded enum]
ELSE …etc…
END )
END )
END )I …just… :((
I just posted "Really???" talking about a 790 line sproc. At least the original author seems to never have heard of CASE before. :laugh: I'm hoping the batches and enums were different each time. :) (doesn't make it any better.) I'm not a fan of CASE, but I've just hit two updates in a row with minor changes that could be handled better with a few well placed CASE statements. Peppered throughout this, it joins a field with 6 function calls to a passed tabular type, then to make extra sure, (s)he put in a matching where clause. I'm thinking that's 1.2 million function calls if there are 10K records in the table and 100 records in the passed table. Nope, it's only 600+K records. The join being mostly false, the WHERE will never be hit. Anyway, I'm a new hire too. Expect some flack as well. If you're curious, see if what I posted beats your's. I think it did.