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. Other Discussions
  3. The Weird and The Wonderful
  4. Good thing we use a transaction...

Good thing we use a transaction...

Scheduled Pinned Locked Moved The Weird and The Wonderful
helpquestion
7 Posts 7 Posters 6 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.
  • G Offline
    G Offline
    GibbleCH
    wrote on last edited by
    #1

    Ok, I come across stuff like this daily...but this one was the most recent CREATE PROC foo BEGIN TRANSACTION SELECT @id = id FROM ... IF @id IS NOT NULL BEGIN ...do some stuff, there is NO ROLLBACK in here or error checking... COMMIT END else ROLLBACK It's just so...useless. We only ever rollback if we didn't do anything?

    C P X 3 Replies Last reply
    0
    • G GibbleCH

      Ok, I come across stuff like this daily...but this one was the most recent CREATE PROC foo BEGIN TRANSACTION SELECT @id = id FROM ... IF @id IS NOT NULL BEGIN ...do some stuff, there is NO ROLLBACK in here or error checking... COMMIT END else ROLLBACK It's just so...useless. We only ever rollback if we didn't do anything?

      C Offline
      C Offline
      Chris Meech
      wrote on last edited by
      #2

      That makes the ROLLBACK extremely fast. ;P

      Chris Meech I am Canadian. [heard in a local bar] Stercorum pro cerebro habes. [Cicero]

      M 1 Reply Last reply
      0
      • G GibbleCH

        Ok, I come across stuff like this daily...but this one was the most recent CREATE PROC foo BEGIN TRANSACTION SELECT @id = id FROM ... IF @id IS NOT NULL BEGIN ...do some stuff, there is NO ROLLBACK in here or error checking... COMMIT END else ROLLBACK It's just so...useless. We only ever rollback if we didn't do anything?

        P Offline
        P Offline
        Pete OHanlon
        wrote on last edited by
        #3

        GibbleCH wrote:

        It's just so...useless. We only ever rollback if we didn't do anything?

        Defensive coding at its finest.:-D

        Deja View - the feeling that you've seen this post before.

        1 Reply Last reply
        0
        • G GibbleCH

          Ok, I come across stuff like this daily...but this one was the most recent CREATE PROC foo BEGIN TRANSACTION SELECT @id = id FROM ... IF @id IS NOT NULL BEGIN ...do some stuff, there is NO ROLLBACK in here or error checking... COMMIT END else ROLLBACK It's just so...useless. We only ever rollback if we didn't do anything?

          X Offline
          X Offline
          Xiangyang Liu
          wrote on last edited by
          #4

          GibbleCH wrote:

          It's just so...useless. We only ever rollback if we didn't do anything?

          Well, maybe you didn't see a "set XACT_ABORT on" statement buried in the code? If that is set, then rollback is automatic whenever an error occurs.

          My .NET Business Application Framework My Home Page

          P 1 Reply Last reply
          0
          • X Xiangyang Liu

            GibbleCH wrote:

            It's just so...useless. We only ever rollback if we didn't do anything?

            Well, maybe you didn't see a "set XACT_ABORT on" statement buried in the code? If that is set, then rollback is automatic whenever an error occurs.

            My .NET Business Application Framework My Home Page

            P Offline
            P Offline
            PIEBALDconsult
            wrote on last edited by
            #5

            Then get rid of the existing ROLLBACK.

            K 1 Reply Last reply
            0
            • P PIEBALDconsult

              Then get rid of the existing ROLLBACK.

              K Offline
              K Offline
              KarstenK
              wrote on last edited by
              #6

              This has a real drawback: you wont see that the code is poor. :((

              Greetings from Germany

              1 Reply Last reply
              0
              • C Chris Meech

                That makes the ROLLBACK extremely fast. ;P

                Chris Meech I am Canadian. [heard in a local bar] Stercorum pro cerebro habes. [Cicero]

                M Offline
                M Offline
                Muammar
                wrote on last edited by
                #7

                Chris Meech wrote:

                That makes the ROLLBACK extremely fast.

                :laugh::laugh:


                Smile: A curve that can set a lot of things straight! (\ /) (O.o) (><)

                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