Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

SQL Server transaction won't roll back?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    SQL Server transaction won't roll back?

    I wonder if I'm doing something wrong here: SQL Server 2008 BeginTransaction -> RollBackTransaction() appears to work fine in Xbasic code, but the data in the backend database is not rolled back for some reason.

    Here's my code snippet:

    Code:
    errors = 0
    
    if conn.open("::Name::PSShip")
    	if conn.BeginTransaction()
              (do stuff such as inserts, selects, etc., increment error counter if there are errors)
                 if errors>0
    		if conn.CommitTransaction()
    			cResult = "Success (committed)"
    		end if
    	   else
    	      if .NOT. conn.RollBackTransaction()
    		cResult = "Error: Unable to roll back transaction."
    	      else
    		cResult = "Success (Rolled back)"
    	      end if
    	   end if
          end if
    end if
    When I trigger an error intentionally in one of the statements after some data has already been inserted within the transaction, the system indicates rollback success, but the data inserted into the database before the error is retained in the database.

    Any ideas?

    #2
    Re: SQL Server transaction won't roll back?

    I haven't tried to duplicate your code yet... but... are you sure you should be testing CommitTransaction() and RollBackTransaction()?

    I thought it was....

    Code:
    conn.BeginTransaction()
    if .not. conn.Execute(sqlStmt) then
       conn.RollBackTransaction()
    else
       conn.CommitTransaction()
    end if

    Comment


      #3
      Re: SQL Server transaction won't roll back?

      One thing that I see is that your code should read "if errors = 0" prior to your commit otherwise you are telling the system to commit when you have errors and rollback when you don't.
      Brad Weaver, President
      ComputerAid International
      Ottawa ON Canada
      Versailles KY USA
      www.compuaid.com

      Comment


        #4
        Re: SQL Server transaction won't roll back?

        Thanks, David --

        Except for the "if errors > 0" -logic error, that's exactly what I'm doing. I actually just threw in the "errors > 0" code as an afterthought to this post, my actual code does much more complex and sophisticated error checking, but I didn't want to include it because it would distract from the core problem.

        The question still remains as to why Xbasic tells me rollback was successful, but SQL Server doesn't act on it. Transactions are such an important part of the multi-table update that my code is trying to accomplish that I would sure love to have them work as expected rather than trying to write my own code to delete parent records if children records are not successfully committed.

        Maybe I'll do more testing with a much simpler setup to see if something in my code between begin and end transaction throws the things off kilter.

        On a separate nit: Why would A5 documentation state that API_UUID() returns a 32 character string, when it clearly returns a 36 character string (albeit with 4 dashes)? Things like this drive me up the wall, because my SQL inserts fail due to the fact that I'm trying to stuff a 36 character GUID into a 32 character space, and then I have to somehow figure out that the documentation,rather than my own code or something in the SQL server itself is wrong. Makes me wary of anything I do with A5/AA before empirically verifying that the code does what the documentation says it does. Makes for long development cycles and cranky programmers...

        Comment


          #5
          Re: SQL Server transaction won't roll back?

          Why would A5 documentation state that API_UUID() returns a 32 character string, when it clearly returns a 36 character string (albeit with 4 dashes)?
          Well, yeah, Alpha documentation....

          Use: remspecial(api_uuidcreate())
          Peter
          AlphaBase Solutions, LLC

          [email protected]
          https://www.alphabasesolutions.com


          Comment


            #6
            Re: SQL Server transaction won't roll back?

            Right, I noticed that in (I think your) earlier posts. I think I will rather make the column wide enough to save me from additional potential for errors and unnecessary typing in the future. Disk space is cheap these days...

            Comment


              #7
              Re: SQL Server transaction won't roll back?

              In fairness to Alpha while they misleadingly state that it returns a 32 character string in the body of the documentation they do mention that the 32 character does not include the four dashes.

              This is a 32 character (128 bit) hexadecimal string (not including dashes)
              Based on their documentation I'd have set the field length to 32 as well.
              Brad Weaver, President
              ComputerAid International
              Ottawa ON Canada
              Versailles KY USA
              www.compuaid.com

              Comment


                #8
                Re: SQL Server transaction won't roll back?

                Brad --

                You are correct, and I didn't see the disclaimer (and if I didn't see it, I'm sure a lot of other busy programmers won't see it, either.) It is an odd way to write documentation, though -- I would much rather have it say: "This is a 36 character string (32 characters without dashes)..." In other words, highlight the default but mention an option, rather than the other, rather obtuse, way around.

                While A5/AA is a great tool once you learn to work around it's quirks and dark corners, it would be much greater if the written documentation was kept up-to-date, easier to search, and with many more examples. To me, for example the .NET documentation is a good example of a great help system.


                Onwards...

                Comment

                Working...
                X