Bug of the day
-
Using all caps for the Transact SQL operators is SO last century. :)
There is only one Vera Farmiga and Salma Hayek is her prophet! Advertise here – minimum three posts per day are guaranteed.
I'm old school
cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP
-
I've been banging my head against a wall trying to work out why a class in a stored procedure was being skipped.
DECLARE @SuppressionMethod varchar(20)
-- ... lots of code...
SET @SuppressionMethod = 'SkipSuppressedMembers'
If lower(@SuppressionMethod) = 'skipsuppressedmembers'
Begin
...No matter what, the if clause was never entered. Can anyone see the head slapper? It's a groaner.
cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP
Is there a good reason why you declared it only 20 chars long? Just checking... My auto-default for in-proc literals is nvarchar(255), just cos I have to deal with localised strings and 255 is generally long enough that I don't have to worry about catching these kinds of bugs.
Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. Complex is better than complicated. Flat is better than nested. Sparse is better than dense. In the face of ambiguity, refuse the temptation to guess.
-
I've been banging my head against a wall trying to work out why a class in a stored procedure was being skipped.
DECLARE @SuppressionMethod varchar(20)
-- ... lots of code...
SET @SuppressionMethod = 'SkipSuppressedMembers'
If lower(@SuppressionMethod) = 'skipsuppressedmembers'
Begin
...No matter what, the if clause was never entered. Can anyone see the head slapper? It's a groaner.
cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP
assignment instead of equality check? Shoulda used yoda code. [edit] Ok, so after looking at the other responses i was way off, I guess. Still, is that not stringly typed code? [/edit]
Pete
-
Is there a good reason why you declared it only 20 chars long? Just checking... My auto-default for in-proc literals is nvarchar(255), just cos I have to deal with localised strings and 255 is generally long enough that I don't have to worry about catching these kinds of bugs.
Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. Complex is better than complicated. Flat is better than nested. Sparse is better than dense. In the face of ambiguity, refuse the temptation to guess.
It was set at a value guaranteed to be longer than what I would need. You can see the irony, of course.
cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP
-
I've been banging my head against a wall trying to work out why a class in a stored procedure was being skipped.
DECLARE @SuppressionMethod varchar(20)
-- ... lots of code...
SET @SuppressionMethod = 'SkipSuppressedMembers'
If lower(@SuppressionMethod) = 'skipsuppressedmembers'
Begin
...No matter what, the if clause was never entered. Can anyone see the head slapper? It's a groaner.
cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP
-
Ah, suppressing members now? We are the 99% you know. ;)
"I have a theory that the truth is never told during the nine-to-five hours. " — Hunter S. Thompson
-
I've been banging my head against a wall trying to work out why a class in a stored procedure was being skipped.
DECLARE @SuppressionMethod varchar(20)
-- ... lots of code...
SET @SuppressionMethod = 'SkipSuppressedMembers'
If lower(@SuppressionMethod) = 'skipsuppressedmembers'
Begin
...No matter what, the if clause was never entered. Can anyone see the head slapper? It's a groaner.
cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP
-
Ah, you just need a 6 fingered foot then you wouldn't have missed that. Fingers and toes - helping people count since year dot.
Well, males do have an extra digit. :sigh:
-
I've been banging my head against a wall trying to work out why a class in a stored procedure was being skipped.
DECLARE @SuppressionMethod varchar(20)
-- ... lots of code...
SET @SuppressionMethod = 'SkipSuppressedMembers'
If lower(@SuppressionMethod) = 'skipsuppressedmembers'
Begin
...No matter what, the if clause was never entered. Can anyone see the head slapper? It's a groaner.
cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP
well I see this has already been answered but I like to use print to see what variables really are
DECLARE @SuppressionMethod varchar(20)
-- ... lots of code...
SET @SuppressionMethod = 'SkipSuppressedMembers'
print @SuppressionMethod
--returns SkipSuppressedMember -
I've been banging my head against a wall trying to work out why a class in a stored procedure was being skipped.
DECLARE @SuppressionMethod varchar(20)
-- ... lots of code...
SET @SuppressionMethod = 'SkipSuppressedMembers'
If lower(@SuppressionMethod) = 'skipsuppressedmembers'
Begin
...No matter what, the if clause was never entered. Can anyone see the head slapper? It's a groaner.
cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP
In this case, blame can be put on the programming language: it should have warned you of the string overflow. Computers are ill-mannered when they do not tell us about our mistakes that they have spotted.
-
Do you see how smug everyone else is that they can count and you can't? I won't belittle you the way the others have.
Forgive your enemies - it messes with their heads
"Mind bleach! Send me mind bleach!" - Nagy Vilmos
My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility
It's to mask the fact they are worse on everything else.
"To alcohol! The cause of, and solution to, all of life's problems" - Homer Simpson
-
I've been banging my head against a wall trying to work out why a class in a stored procedure was being skipped.
DECLARE @SuppressionMethod varchar(20)
-- ... lots of code...
SET @SuppressionMethod = 'SkipSuppressedMembers'
If lower(@SuppressionMethod) = 'skipsuppressedmembers'
Begin
...No matter what, the if clause was never entered. Can anyone see the head slapper? It's a groaner.
cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP
SkipSuppressedMembers has 21 chars, not 20. You're comparing lower('SkipSuppressedMember') against skipsuppressedmembers
-
I've been banging my head against a wall trying to work out why a class in a stored procedure was being skipped.
DECLARE @SuppressionMethod varchar(20)
-- ... lots of code...
SET @SuppressionMethod = 'SkipSuppressedMembers'
If lower(@SuppressionMethod) = 'skipsuppressedmembers'
Begin
...No matter what, the if clause was never entered. Can anyone see the head slapper? It's a groaner.
cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP
To feed the trolls and have the string fit in the variable, you might consider increasing the length of said troll variable. Other problems in the code, using 'lower' to do a string comparission in SQL, which is case insensitive (unless you start toying with the collation).
-
I've been banging my head against a wall trying to work out why a class in a stored procedure was being skipped.
DECLARE @SuppressionMethod varchar(20)
-- ... lots of code...
SET @SuppressionMethod = 'SkipSuppressedMembers'
If lower(@SuppressionMethod) = 'skipsuppressedmembers'
Begin
...No matter what, the if clause was never entered. Can anyone see the head slapper? It's a groaner.
cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP
-
I've been banging my head against a wall trying to work out why a class in a stored procedure was being skipped.
DECLARE @SuppressionMethod varchar(20)
-- ... lots of code...
SET @SuppressionMethod = 'SkipSuppressedMembers'
If lower(@SuppressionMethod) = 'skipsuppressedmembers'
Begin
...No matter what, the if clause was never entered. Can anyone see the head slapper? It's a groaner.
cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP
-
It should be a SELECT, not a SET?.
Psychosis at 10 Film at 11 Those who do not remember the past, are doomed to repeat it. Those who do not remember the past, cannot build upon it.
No. Take a look at the other zillion responses :)
cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP
-
I've been banging my head against a wall trying to work out why a class in a stored procedure was being skipped.
DECLARE @SuppressionMethod varchar(20)
-- ... lots of code...
SET @SuppressionMethod = 'SkipSuppressedMembers'
If lower(@SuppressionMethod) = 'skipsuppressedmembers'
Begin
...No matter what, the if clause was never entered. Can anyone see the head slapper? It's a groaner.
cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP
After fixing the size of the SuppressionMethod, it seems like you will also have a problem with the "if" in that, you are assigning the values, not really checking to see if it is... If lower(@SuppressionMethod) = 'skipsuppressedmembers' Begin Should be... [IMHO] if lower(@SuppressionMethod) == 'skipsuppressedmembers' Begin Just a thought.
-
Very good :thumbsup:
cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP
I first saw a bug like that in the 1980s, in Fortran. The system fell over on startup on Monday, 2nd September. Hint 1: The office was closed and the system shut down over the weekend. Hint 2: Which month has the longest name (it was English)? (And it wasn't me who did it!)
-
After fixing the size of the SuppressionMethod, it seems like you will also have a problem with the "if" in that, you are assigning the values, not really checking to see if it is... If lower(@SuppressionMethod) = 'skipsuppressedmembers' Begin Should be... [IMHO] if lower(@SuppressionMethod) == 'skipsuppressedmembers' Begin Just a thought.
Member 8382884 wrote:
if lower(@SuppressionMethod) == 'skipsuppressedmembers'
BeginHave you tried entering that in an SQL editor and running it? Just a thought.
Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. Complex is better than complicated. Flat is better than nested. Sparse is better than dense. In the face of ambiguity, refuse the temptation to guess.
-
I've been banging my head against a wall trying to work out why a class in a stored procedure was being skipped.
DECLARE @SuppressionMethod varchar(20)
-- ... lots of code...
SET @SuppressionMethod = 'SkipSuppressedMembers'
If lower(@SuppressionMethod) = 'skipsuppressedmembers'
Begin
...No matter what, the if clause was never entered. Can anyone see the head slapper? It's a groaner.
cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP
Well, aside from the obvious which everyone else has commented on, my first question would be "Why is he checking a value that he just set in the previous statement?" Was there some other code that you omitted?