Alpha Video Training
Results 1 to 12 of 12

Thread: Using Table.open_session in multi user environment

  1. #1
    "Certified" Alphaholic MoGrace's Avatar
    Real Name
    Robin
    Join Date
    Mar 2006
    Location
    Los Angeles
    Posts
    3,595

    Default Using Table.open_session in multi user environment

    I often use tbl.open_session() in a script for one table when I want to add or change records and the likelyhood exists that it may already be opened by another user like when a form is opened by more than one user.

    I have a new script that opens two tables and the script will interact between them fetching thru one to change or enter records in the other.

    So my question is: If each table is opened in its own session - will my table pointers work the same way as when each is opened in the same session?

    I am also using the FILE_RW_SHARED flag.

    In this script I am updating a one record temp table before printing a report and it is quite likely more than one user may be trying to do the same...
    Last edited by MoGrace; 05-09-2019 at 03:16 PM. Reason: more info added
    Robin

    Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

  2. #2
    Member
    Real Name
    Andrew Davidowicz
    Join Date
    Aug 2018
    Posts
    9

    Default Re: Using Table.open_session in multi user environment

    Hey Robin, sorry that I don't have an answer for your question but I have a question about tbl.open_session().

    I have now been working with Alpha for 9 months now and all the previous developers for my agency have only used tbl.open() for everything. After seeing your post about tbl.open_session() it intrigued me to look into that function but unfortunately the help file does not really go into depth about any advantages or the correct usage of it.

    If you can shed any more details in why you use that function over tbl.open it would be most helpful!

    (Background: We have over 240 users constantly adding/editing/removing data from our tables using our scripts that only use tbl.open() when pointing to a table.)

  3. #3
    "Certified" Alphaholic MoGrace's Avatar
    Real Name
    Robin
    Join Date
    Mar 2006
    Location
    Los Angeles
    Posts
    3,595

    Default Re: Using Table.open_session in multi user environment

    Hi Andrew,
    The main purpose is as I stated above: If I am using a button on a form or calling a script that will be writing to tables that are likely open/in use, then I use open_session to hopefully avoid conflicts with current data entry. Each time the table is open it gets an alias anyway for the current pointer, but this seemed like it might work better in a multi-user setup.

    So that's my "I don't know either" response!

    From the Wiki: The TABLE.OPEN_SESSION() method allows you to open a table more than once (in a different sessions).
    Robin

    Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

  4. #4
    Member
    Real Name
    Andrew Davidowicz
    Join Date
    Aug 2018
    Posts
    9

    Default Re: Using Table.open_session in multi user environment

    Haha, that did clear it up a little more for me! Thanks!

  5. #5
    "Certified" Alphaholic
    Real Name
    Finian Lennon
    Join Date
    Apr 2000
    Location
    Atlanta, GA
    Posts
    1,799

    Default Re: Using Table.open_session in multi user environment

    Robin:

    One way to avoid the kind of conflicts that you mention is to add a "User" field to the temp table. (Assuming your users login and have unique sign-in values.) Then, when User A is adding values to the temp table (I eventually gave up on single record temp tables. Instead I created a full set of table clones for the set and wrote the required records from each table into its clone. A pain to set up and maintain but eliminated all printing problems no matter how many users were active and the main transaction tables were getting huge. But I digress) the record is marked with that user's login. So step 1, query the temp table for that user's records, then delete_range(), then add the new record(s). Then filter the report for that user's records. All using table.open and no user conflicts or concerns about who is doing what to whom. And although it seems cumbesome, it is really fast.
    Finian

  6. #6
    "Certified" Alphaholic MoGrace's Avatar
    Real Name
    Robin
    Join Date
    Mar 2006
    Location
    Los Angeles
    Posts
    3,595

    Default Re: Using Table.open_session in multi user environment

    Thanks for that idea Finian - I do have a user_id I could use. I will have to consider how to set this up but it sounds workable...

    I take it you read my other thread on creating a temp table for a report?
    Robin

    Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

  7. #7
    "Certified" Alphaholic
    Real Name
    Finian Lennon
    Join Date
    Apr 2000
    Location
    Atlanta, GA
    Posts
    1,799

    Default Re: Using Table.open_session in multi user environment

    <I take it you read my other thread on creating a temp table for a report?>
    I did but have been too stuck in some non-Alpha work to be able to participate much in the discussions. Filtering by the user id was an idea I got from Peter Wayne way back in V5 days when we were really struggling to print complex oral surgery office bills and create medical and dental insurance submissions. When the tables got big, we had issues. It evolved to where just about all the invoices and insurance submissions were generated from temp tables, filtered by users. The main difficulty was remembering to synch the clone table structures when the production tables were reconfigured,
    Finian

  8. #8
    "Certified" Alphaholic MoGrace's Avatar
    Real Name
    Robin
    Join Date
    Mar 2006
    Location
    Los Angeles
    Posts
    3,595

    Default Re: Using Table.open_session in multi user environment

    It turns out the one-record table was pretty much useless for the report because of the inability to print a decent check box without having to create 40 calculated fields to do so. Instead I added a character field with a field rule calc in the template table that fills it with an 'X' when the logical field is .t. Then that field with a border is what is used on the report. Saving the report data is not necessary anyway since the report can be produced on the fly. So no live tables need to be written to, only read and copied to the template table. Therefore using open_session for the template table is probably not necessary.
    Robin

    Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

  9. #9
    "Certified" Alphaholic DaveM's Avatar
    Real Name
    Dave Mason
    Join Date
    Jul 2000
    Location
    Hudson, FL
    Posts
    5,994

    Default Re: Using Table.open_session in multi user environment

    One record temp table is what I use, but it is a local table where all my app is on a server except the temp table which is a live table in the shadow. I just zap the table and then refill as work needs come up. Even though the app is used by 20-40 users at a time, I dreamed of the several issues that could occur if it were on a server. It is only used to print a credit application and a bank contract or lease with Crystal Reports. Yes, Robin, Lightning fast.
    Dave Mason
    dave@aldaweb.com

    Skype is dave.mason46

  10. #10
    "Certified" Alphaholic MoGrace's Avatar
    Real Name
    Robin
    Join Date
    Mar 2006
    Location
    Los Angeles
    Posts
    3,595

    Default Re: Using Table.open_session in multi user environment

    Hi Dave,
    So when you are developing an app that will be used in a runtime client/server setup - do you mimic the final location for the file on your c:\drive so your scripts can find the right table? Or how do you do this?
    Robin

    Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

  11. #11
    "Certified" Alphaholic DaveM's Avatar
    Real Name
    Dave Mason
    Join Date
    Jul 2000
    Location
    Hudson, FL
    Posts
    5,994

    Default Re: Using Table.open_session in multi user environment

    Quote Originally Posted by MoGrace View Post
    Hi Dave,
    So when you are developing an app that will be used in a runtime client/server setup - do you mimic the final location for the file on your c:\drive so your scripts can find the right table? Or how do you do this?
    I use a join filtered by id to fill the temp table when the print button is pressed. I install the temp table after all other is installed. tabled is made part of the cpanel from autoexec if needed.

    Pretty simple.
    Dave Mason
    dave@aldaweb.com

    Skype is dave.mason46

  12. #12
    "Certified" Alphaholic
    Real Name
    Finian Lennon
    Join Date
    Apr 2000
    Location
    Atlanta, GA
    Posts
    1,799

    Default Re: Using Table.open_session in multi user environment

    PMFBI but FWIW, in my current application, every user gets their own sub-folder (off the main app folder) where we store a bunch of temp tables built for specific purposes. The first time the user logs in the user folder is created and the temp tables copied in. After that, on startup, every user gets global variables pointing to the main app folder and to their sub-folder. From time to time we have put also files into the shadow folder on the local machine, but the main thing is that each user can have their own place for temp files.
    Finian

Similar Threads

  1. Multi User Environment
    By NormanMouton in forum Alpha Five Version 9 - Desktop Applications
    Replies: 2
    Last Post: 09-30-2009, 04:08 PM
  2. Database updates in multi user environment
    By flord in forum Alpha Five Version 9 - Desktop Applications
    Replies: 2
    Last Post: 02-17-2009, 12:24 PM
  3. Multi-user environment
    By G Gabriel in forum Alpha Five Version 8
    Replies: 11
    Last Post: 07-24-2007, 03:39 PM
  4. DELETE_RANGE() in a multi-user environment? What should I use instead?
    By Jeff@Listbrokers in forum Alpha Five Version 7
    Replies: 17
    Last Post: 10-15-2006, 07:29 PM
  5. Multi user environment
    By Charles Castellano in forum Alpha Five Version 5
    Replies: 14
    Last Post: 10-20-2004, 09:07 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •