none
How can a simple select command produce "File is in use by another" RRS feed

  • Question

  • how can this command:

    SELECT * FROM stocklist WHERE design = tmpcpo.design AND size = tmpcpo.size INTO CURSOR curStckList

    Cause "File is in use by another"  error?

    Thanks!

    Wednesday, June 19, 2019 5:35 AM

Answers

  • In use by another user always refers to a shared table which is written to at the time you want to use it. The help on error tells it's only associated with USE, DELETE or RENAME, but USE also is done by SQL-SELECT, of course.

    So if tmpcpo is already used and the recordpointer doesn't point to EOF(), then it'll be about stocklist.

    But typically that doesn't play a role as VFP is reprocessing such things failing at first. You'd have to have SET REPROCESS to something like low number of reattempts or even none. Maybe even for reasons of previous locking problems.

    In the end it is inevitable to have special handling of error 108 retrying after a random short time.

    Bye, Olaf.


    • Marked as answer by Aleniko2 Thursday, July 4, 2019 9:19 PM
    Thursday, July 4, 2019 6:59 AM

All replies

  • Use SET EXCLUSIVE OFF in Load/InIt even of main form.

    OR

    Write before that query:

    IF USED('stocklist')
    USE IN stocklist
    ENDIF

    • Edited by ShahidSQL Wednesday, June 19, 2019 7:06 AM
    Wednesday, June 19, 2019 7:06 AM
  • Exclusive is off - but that can't be the issue.

    I also issue a USE IN "STOCKLIST"  after the select is issued.

    Thanks.

    Wednesday, June 19, 2019 5:36 PM
  • after the SELECT or before the SELECT ?
    Thursday, June 20, 2019 3:07 AM
  • After
    Wednesday, June 26, 2019 4:27 AM
  • What's tmpcpo here? If it's an alias, it's unusual to refer to fields of a table that's not included in the query.

    Tamar

    Wednesday, June 26, 2019 8:12 PM
    Moderator
  • Aleniko,

    1. If you don't have the table open already and the default for SET EXCLUSIVE is ON, when you issue the SELECT command, it will open EXCLUSIVE; to avoid this, you can issue a SET EXCLUSIVE OFF at the beginning of the Program/project
    2. As Tamar asked before, what is tmpcpo? If it is a separate cursor or table , you will need to add it into the select command; in addition, it both tables share field names, you will need to indicate what table the * belons to.  SELECT stocklist.* FROM stocklist, tmpcpo WHERE design = tmpcpo.design AND size = tmpcpo.size INTO CURSOR curStckList
    Monday, July 1, 2019 3:45 PM
    Moderator
  • Tamar and Benny;

    As I said before, exclusive is set to off. This is a multi user system with 30 or so users using it all the time.

    tmpcpo is a table and its used in this case just to statically reference what we are looking for. So I don't need any relations / joins or any other reference to it. So i effect its just like saying

    " where design = cDesign and size= cSize"

    Also, this is working fine in 99.9% of the cases. Once in a blue moon one of the users will get this error, and the error line in the source code refers to this command. Its just seems impossible.

    And again, even if exclusive was on, the error message generated won't be file is in use by another but rather file access denied.

    thanks!

    Wednesday, July 3, 2019 1:10 AM
  • Let's get tmpcpo out of the equation. Copy the field or fields you need to variables and use them in the query.

    Tamar

    Wednesday, July 3, 2019 8:19 PM
    Moderator
  • In use by another user always refers to a shared table which is written to at the time you want to use it. The help on error tells it's only associated with USE, DELETE or RENAME, but USE also is done by SQL-SELECT, of course.

    So if tmpcpo is already used and the recordpointer doesn't point to EOF(), then it'll be about stocklist.

    But typically that doesn't play a role as VFP is reprocessing such things failing at first. You'd have to have SET REPROCESS to something like low number of reattempts or even none. Maybe even for reasons of previous locking problems.

    In the end it is inevitable to have special handling of error 108 retrying after a random short time.

    Bye, Olaf.


    • Marked as answer by Aleniko2 Thursday, July 4, 2019 9:19 PM
    Thursday, July 4, 2019 6:59 AM
  • Olaf;

    This at least makes some sense.

    It is possible that some slow machine on the network is holding the file locked and so other machines fail. Reprocess is set to "2 seconds system", but looking at code reference I see a place in which reprocess is set to 25.

    Probably that's the issue.

    Thanks again, because I didn't think a simple select command would  ever generate that error.


    Thursday, July 4, 2019 9:17 PM
  • Tamar - If it was the tmpcpo I would be getting these errors all the time.

    I think olaf lead me to the right solution.

    Thanks!

    Thursday, July 4, 2019 9:18 PM