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

Multi-User Record Contention

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

    Multi-User Record Contention


    I posted this in a conversation in A5 v10, and then realized it is more appropriate in v12 where more users will see it. Is there a way to place the "a_tbl.is_record_locked()" as a filter in an operation (without converting the operation to an Xbasic loop) so that it just skips the record that is locked?

    #2
    Sorry but more info needed.
    Usually Alpha handles record locking in a distributed environment like Runtime and with Network Optimisation.
    This should be the same in V10.5.

    So.
    How is your system set up?
    Are you specifically asking about V10, or 10.5?
    Why are you trying to skip around locked records anyway?
    What is your ideal scenario?
    See our Hybrid Option here;
    https://hybridapps.example-software.com/


    Apologies to anyone I haven't managed to upset yet.
    You are held in a queue and I will get to you soon.

    Comment


      #3
      Ted --

      Thank you for your prompt response. We are using A5 version 12 build 4119. The application was written for a single (desktop) user, but now we have a master and a shadow setup at some locations. When the shadow opens a certain form, it prevents the master from completing an update operation on the table that is used in the form opened by the shadow. The master reports that the table is in use.

      I have been able to program around the problem for some operations by converting the operation to an Xbasic loop, testing to see if the record is locked, and then skipping that record. However, it would be a lot easier if I could just install a filter on the operation to skip locked records. Is there an easy way to do this?

      -- Dick James

      Comment


        #4
        It looks a lot like a design issue, Dick.

        Look around the Form you are having issues with for any setting of EXCLUSIVE which will lock out records.

        It will be set somewhere as File.open(). Look in the documentation for that "Method".

        Unfortunately single use systems can be problematic when simply distributed. You are using Network Optimisation I assume from your use of the term "Shadowed"?
        See our Hybrid Option here;
        https://hybridapps.example-software.com/


        Apologies to anyone I haven't managed to upset yet.
        You are held in a queue and I will get to you soon.

        Comment


          #5
          Ted --

          It is definitely a bad design. I was new to Alpha when I began developing this application, and I primarily used action scripts to get started. I'll take a look at the Xbasic behind the action scripts to see how the forms are being opened. That may be a good interim solution.

          We are using our application at about 30 locations, and fewer than 10 are multiuser. Most of those users have learned to work around the contention issue, but it is annoying for new users.

          Accordingly, we are developing a replacement system in Alpha designed for multiple users. However, the progress has been slow. We were able to convert our data base to SQL fairly quickly, but the redevelopment of the forms to UXs to display properly in a browser has been challenging. We also are finding that our forms with a large number of fields seem to load slowly when all of the fields are placed in one UX. We will probably have to break up those forms into multiple UXs for each form.

          I would still be interested in knowing if it is possible to place a filter on an operation called by an action script where the filter instructs the operation to skip locked records. That would temporarily eliminate the problem of the application occasionally "hanging". The skipped records will always be updated at the end of the day when the DB is backed up and only the master has use of the DB.

          Thanks.

          -- Dick James

          Comment


            #6
            Dick, a couple of ideas for you.

            I'm assuming you're using native Alpha tables (DBF).

            1) It would be helpful if you could explain / show your code that "skips" the "locked" record. I know that the table is opened when the form is opened, but opening the form does not (I think) lock any records. That occurs when a change begins or a new record is started. What may be happening is that your particular operation needs "exclusive" use of the table, and fails whether an edit or enter is in process. I suspect it would fail if the table was "open" anywhere on the network, regardless of the data entry mode of the form.

            2) You can test for "table in use" before running your operation. Check the docs for the table.in_use() function.

            3) Be careful with using the word "operation" here. Longtime Alpha Five / Alpha Anywhere users infer that this refers to a "saved operation", found on the Operations tab of the desktop control panel. However, the word "operation" can also mean an xbasic script that steps through a series of records one at a time, and modifies them or skips them as appropriate. One way to distinguish "saved operations" from scripts that process records in sequence (in this forum) is to mention the operation "type" in the post. i.e. append, post, update, export, etc.

            I hope this is helpful and wish you success with your project.

            -- tom

            Comment


              #7
              Tom --

              We have been using DBF tables. The operations are update operations created by the genie that can be used to create the operation and then called with one action script command. The Xbasic code that is created by the genie looks like this:

              Code:
              'opnClearUpgradeValues -- saved update operation.
              
              a_tbl = table.open("tblunitinformation")
              ON ERROR GOTO ERROR13092021091030293
              
              
              DIM a5_operation_order as C
              a5_operation_order = ""
              query.order = a5_operation_order
              DIM a5_operation_filter as C
              a5_operation_filter = ".T."
              query.filter = a5_operation_filter
              query.options = "I"
              query.description = "Temporary Query"
              i_indx = a_tbl.query_create("N")
              
              update.fields = 12
              update.field1 = "XFEATURE1VALUE"
              update.expr1 = "if(XFEATURE1EXPIRES<=date(),0,XFEATURE1VALUE)"
              update.field2 = "XFEATURE2VALUE"
              update.expr2 = "if(XFEATURE2EXPIRES<=date(),0,XFEATURE2VALUE)"
              update.field3 = "XFEATURE3VALUE"
              update.expr3 = "if(XFEATURE3EXPIRES<=date(),0,XFEATURE3VALUE)"
              update.field4 = "XFEATURE4VALUE"
              update.expr4 = "if(XFEATURE4EXPIRES<=date(),0,XFEATURE4VALUE)"
              update.field5 = "XFEATURE1"
              update.expr5 = "if(XFEATURE1EXPIRES<=date(),\"\",XFEATURE1)"
              update.field6 = "XFEATURE2"
              update.expr6 = "if(XFEATURE2EXPIRES<=date(),\"\",XFEATURE2)"
              update.field7 = "XFEATURE3"
              update.expr7 = "if(XFEATURE3EXPIRES<=date(),\"\",XFEATURE3)"
              update.field8 = "XFEATURE4"
              update.expr8 = "if(XFEATURE4EXPIRES<=date(),\"\",XFEATURE4)"
              update.field9 = "XFEATURE1EXPIRES"
              update.expr9 = "if(XFEATURE1EXPIRES<=date(),{//},XFEATURE1EXPIRES)"
              update.field10 = "XFEATURE2EXPIRES"
              update.expr10 = "if(XFEATURE2EXPIRES<=date(),{//},XFEATURE2EXPIRES)"
              update.field11 = "XFEATURE3EXPIRES"
              update.expr11 = "if(XFEATURE3EXPIRES<=date(),{//},XFEATURE3EXPIRES)"
              update.field12 = "XFEATURE4EXPIRES"
              update.expr12 = "if(XFEATURE4EXPIRES<=date(),{//},XFEATURE4EXPIRES)"
              
              a_tbl.update()
              
              
              GOTO CONTINUE13092021091030293
              ERROR13092021091030293:
              ON ERROR GOTO 0
              ui_msg_box("Error","Error running Update Operation"+crlf()+error_text_get())
              END
              CONTINUE13092021091030293:
              a_tbl.close()'If the Operation is run from within a Form or Browse, then refresh the window
              if is_object(topparent.this) then
              if topparent.Class() = "form" .or. topparent.class() = "browse" then
              topparent.Refresh_layout()
              end if
              end if
              
              '-------------------- End of saved update operation.
              The rewritten code in Xbasic saved as a script that skips locked records looks like this:
              Code:
              'scrClearUpgradeValues -- saved update script.
              
              a_tbl = table.open("tblunitinformation")
              ON ERROR GOTO ERROR07082021132346737
              
              'debug(1)
              a_tbl.fetch_first()
              while .not. a_tbl.fetch_eof()[INDENT]If a_tbl.is_record_locked() then[/INDENT][INDENT=2]goto lblGetNext[/INDENT][INDENT]end if
              if a_tbl.xfeature1expires <= date() then[/INDENT][INDENT=2]a_tbl.change_begin()
              a_tbl.xfeature1value= 0
              a_tbl.xfeature1 = ""
              a_tbl.xfeature1expires = { / / }
              a_tbl.change_end(.t.)[/INDENT][INDENT]end if
              if a_tbl.xfeature2expires <= date() then[/INDENT][INDENT=2]a_tbl.change_begin()
              a_tbl.xfeature2value= 0
              a_tbl.xfeature2 = ""
              a_tbl.xfeature2expires = { / / }
              a_tbl.change_end(.t.)[/INDENT][INDENT]end if
              if a_tbl.xfeature3expires <= date() then[/INDENT][INDENT=2]a_tbl.change_begin()
              a_tbl.xfeature3value= 0
              a_tbl.xfeature3 = ""
              a_tbl.xfeature3expires = { / / }
              a_tbl.change_end(.t.)[/INDENT][INDENT]end if
              if a_tbl.xfeature4expires <= date() then[/INDENT][INDENT=2]a_tbl.change_begin()
              a_tbl.xfeature4value= 0
              a_tbl.xfeature4 = ""
              a_tbl.xfeature4expires = { / / }
              a_tbl.change_end(.t.)[/INDENT][INDENT]end if[/INDENT]
               lblGetNext:[INDENT]a_tbl.fetch_next()[/INDENT]
               end while
              
              a_tbl.close()
              end
              
              ERROR07082021132346737:
              ON ERROR GOTO 0
              ui_msg_box("Error","Error running Update Operation"+crlf()+error_text_get())
              
              a_tbl.close()'If the Operation is run from within a Form or Browse, then refresh the window
              end
              
              '------------------ End of saved update script.
              I think the issue is typically occurring when one user starts to enter a change to a record and then leaves the workstation while the record is in change mode. Meanwhile, another user does something to trigger the saved update operation. These operations are also run at night when the shadow workstations are closed, so the data are not more than one day old anyway. However, I would like to eliminate the problem of the DB "hanging". The Xbasic script that skips a locked record seems to fix the problem, but I would like to not have to convert all of the update (and post?) operations since we are in the process of redeveloping the entire application anyway.

              Thanks for your input.

              -- Dick James

              Comment


                #8
                Hello Dick,
                Have you considered using WEB components on the desktop? You can build a UX component and connect the component to a dbf table using an ODBC connection string. With minimal changes, the same component in the future can then be connected to a SQL table.

                NOTE: you can run WEB components inside of the desktop. You do not have to run them in a browser.

                You do not need to use an ODBC connection string. In this case, you will need to write your own xbasic code to submit data to the table. This is the same as using an xdialog as a form for data input.
                The problem with using forms is as you said, a user will put the form in either enter or change mode which will lock the record. And then they go get coffee.
                In my simple way of thinking, UX components are the WEB version of an xdialog where when the component is opened, it reads from the table and then closes the connection. Changes can be made to the UX but they are only sent to the table when the data is submitted. So in each case, reading or writing, the connection is in milliseconds.
                Last edited by Ronald Anusiewicz; 09-13-2021, 10:20 AM. Reason: Added the Note
                Alpha 5 Version 11
                AA Build 2999, Build 4269, Current Build
                DBF's and MySql
                Desktop, Web on the Desktop and WEB

                Ron Anusiewicz

                Comment


                  #9
                  Ron --

                  We (my IT guy and me) have found the development of UXs to replace our forms was slow-going. We started off trying to create UXs that were responsive design. We probably should have created them as absolute containers.

                  In my original post I was inquiring as to whether there was a way to put a filter on an update operation created by a genie that would instruct the saved operation to skip locked records. Evidently, this is not easily done.

                  Comment


                    #10
                    Dick,

                    If the records you wish to update are only the 'expired' ones and they're not going to be updated/in use by the second user, then you can filter your update operation by these fields and just clear those few - you'd need 4 operations looking at your existing code...

                    Code:
                    a_tbl = table.open("tblunitinformation")
                    ON ERROR GOTO ERROR13092021091030293
                    DIM a5_operation_order as C a5_operation_order = ""
                    query.order = a5_operation_order
                    DIM a5_operation_filter as C
                    a5_operation_filter = "XFEATURE1EXPIRES<=date()"
                    query.filter = a5_operation_filter
                    query.options = "I" query.description = "Temporary Query"
                    i_indx = a_tbl.query_create("N")
                    update.fields = 1
                    update.field1 = "XFEATURE1VALUE"
                    update.expr1 = "0"
                    update.field2 = "XFEATURE1"
                    update.expr2 = ""
                    update.field3 = "XFEATURE1EXPIRES"
                    update.expr3 = "{//}"
                    
                    a_tbl.update()
                    GOTO CONTINUE13092021091030293
                    ERROR13092021091030293:
                    ON ERROR GOTO 0
                    ui_msg_box("Error","Error running Update Operation"+crlf()+error_text_get())
                    END
                    CONTINUE13092021091030293:
                    a_tbl.close()
                    May need a bit of tweaking as my copy/paste of the original threw away all line feeds.

                    Comment


                      #11
                      In pseudo code, the logic could be;

                      While record not locked
                      Update records
                      End while

                      It should be relatively easy, but it's possibly a syntax issue.
                      I use a different toolkit for web front ends or hybrids, so as far as your web development goes, Greg is probably a whole lot more AA competent.

                      Having said that, I am sure there is a way around this.
                      See our Hybrid Option here;
                      https://hybridapps.example-software.com/


                      Apologies to anyone I haven't managed to upset yet.
                      You are held in a queue and I will get to you soon.

                      Comment


                        #12
                        Been doing more testing on my version of Alpha.
                        Created an Operation to add random numbers to a table.
                        This was using the standard Update featuire and a batch process.

                        Created a Code script to open and close the table;

                        tbl = table.current()
                        tbl.change_begin()
                        tbl.change_end(.T.)


                        Attached this to a button as 2 Action Scripting events - open close first, create random number second.

                        Opened 5 versions of the form and tried various stages of add/change/delete on each
                        Last form, clicked the button. It all worked. The update process completed and left the unfinished records as they were.

                        BUT. If there is a browse on the form, then the trouble starts and the Operation will not complete and there is an error.
                        See our Hybrid Option here;
                        https://hybridapps.example-software.com/


                        Apologies to anyone I haven't managed to upset yet.
                        You are held in a queue and I will get to you soon.

                        Comment

                        Working...
                        X