Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. Bug of the day

Bug of the day

Scheduled Pinned Locked Moved The Lounge
c++databasearchitecturehelpquestion
42 Posts 32 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Chris Maunder

    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

    S Offline
    S Offline
    Single Step Debugger
    wrote on last edited by
    #19

    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.

    C 1 Reply Last reply
    0
    • S Single Step Debugger

      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.

      C Offline
      C Offline
      Chris Maunder
      wrote on last edited by
      #20

      I'm old school

      cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP

      1 Reply Last reply
      0
      • C Chris Maunder

        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

        M Offline
        M Offline
        Mel Padden
        wrote on last edited by
        #21

        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.

        C 1 Reply Last reply
        0
        • C Chris Maunder

          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

          P Offline
          P Offline
          Peter Mulholland
          wrote on last edited by
          #22

          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

          1 Reply Last reply
          0
          • M Mel Padden

            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.

            C Offline
            C Offline
            Chris Maunder
            wrote on last edited by
            #23

            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

            1 Reply Last reply
            0
            • C Chris Maunder

              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

              W Offline
              W Offline
              wizardzz
              wrote on last edited by
              #24

              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

              E 1 Reply Last reply
              0
              • W wizardzz

                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

                E Offline
                E Offline
                ekolis
                wrote on last edited by
                #25

                Help! I'm being suppressed! *gets thrown into a wheelbarrow* I'm not dead yet! *KATHWACKLE* Now he is...

                1 Reply Last reply
                0
                • C Chris Maunder

                  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

                  J Offline
                  J Offline
                  James H
                  wrote on last edited by
                  #26

                  21 char string literal into 20 char varchar = 'SkipSuppressedMember' losing the s

                  1 Reply Last reply
                  0
                  • J JHizzle

                    Ah, you just need a 6 fingered foot then you wouldn't have missed that. Fingers and toes - helping people count since year dot.

                    S Offline
                    S Offline
                    Steven Nicholas
                    wrote on last edited by
                    #27

                    Well, males do have an extra digit. :sigh:

                    1 Reply Last reply
                    0
                    • C Chris Maunder

                      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

                      E Offline
                      E Offline
                      edmurphy99
                      wrote on last edited by
                      #28

                      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

                      1 Reply Last reply
                      0
                      • C Chris Maunder

                        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

                        Y Offline
                        Y Offline
                        YvesDaoust
                        wrote on last edited by
                        #29

                        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.

                        1 Reply Last reply
                        0
                        • P Pete OHanlon

                          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

                          F Offline
                          F Offline
                          Fabio Franco
                          wrote on last edited by
                          #30

                          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

                          1 Reply Last reply
                          0
                          • C Chris Maunder

                            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

                            V Offline
                            V Offline
                            Victor Ulloa
                            wrote on last edited by
                            #31

                            SkipSuppressedMembers has 21 chars, not 20. You're comparing lower('SkipSuppressedMember') against skipsuppressedmembers

                            1 Reply Last reply
                            0
                            • C Chris Maunder

                              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

                              K Offline
                              K Offline
                              Kabwla Phone
                              wrote on last edited by
                              #32

                              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).

                              1 Reply Last reply
                              0
                              • C Chris Maunder

                                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

                                A Offline
                                A Offline
                                agolddog
                                wrote on last edited by
                                #33

                                How about varchar(more)?

                                1 Reply Last reply
                                0
                                • C Chris Maunder

                                  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

                                  B Offline
                                  B Offline
                                  BrainiacV
                                  wrote on last edited by
                                  #34

                                  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.

                                  C 1 Reply Last reply
                                  0
                                  • B BrainiacV

                                    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.

                                    C Offline
                                    C Offline
                                    Chris Maunder
                                    wrote on last edited by
                                    #35

                                    No. Take a look at the other zillion responses :)

                                    cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP

                                    1 Reply Last reply
                                    0
                                    • C Chris Maunder

                                      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

                                      U Offline
                                      U Offline
                                      User 8347395
                                      wrote on last edited by
                                      #36

                                      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.

                                      M 1 Reply Last reply
                                      0
                                      • C Chris Maunder

                                        Very good :thumbsup:

                                        cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP

                                        B Offline
                                        B Offline
                                        BarrRobot
                                        wrote on last edited by
                                        #37

                                        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!)

                                        1 Reply Last reply
                                        0
                                        • U User 8347395

                                          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.

                                          M Offline
                                          M Offline
                                          Mel Padden
                                          wrote on last edited by
                                          #38

                                          Member 8382884 wrote:

                                          if lower(@SuppressionMethod) == 'skipsuppressedmembers'
                                          Begin

                                          Have 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.

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups