Discussion:
Help understanding COPY TO when a record is locked by another user...
(too old to reply)
Debbie
2005-02-01 16:02:21 UTC
Permalink
Can someone please tell me what would happen in the following situation in a
multi-user environment:

User1 is viewing/editing a record in a table called "orders" and has locked
the record.

At the same time, User2 runs a form and calls a method which has the
following piece of code in it:

SELECT 0
USE orders SHARED
COPY TO (lctemp) FOR orders.ddateplaced = DATE()

The record that User1 has locked falls into the above COPY TO criteria.

My clients are periodically getting a "File is in use" error when they run
the form in question. Would I still get the error message if I changed the
code to use a SELECT-SQL statement? If I would, then can anyone advise me
of the best way to gather records from a table which is heavily used
throughout the day and frequently being edited/viewed/locked.

Thanks - Debbie
Dan Freeman
2005-02-01 17:49:54 UTC
Permalink
"File is in use" isn't caused by record locking. Help says this:

"You have attempted a USE, DELETE, or RENAME command on a file that is
currently open."

Your COPY TO should be just fine. Obviously it won't pick up unsaved changes
by other users, but it shouldn't throw that particular error because of
record locks.

It sounds like you're hard-coding the destination file name in COPY TO and
someone else already has the previously created file open.

Of course, if you're not getting that EXACT error message, all bets are off.
Add "by another" to the message and you've got an entirely different
situation. <g>

Dan
Post by Debbie
Can someone please tell me what would happen in the following
User1 is viewing/editing a record in a table called "orders" and has
locked the record.
At the same time, User2 runs a form and calls a method which has the
SELECT 0
USE orders SHARED
COPY TO (lctemp) FOR orders.ddateplaced = DATE()
The record that User1 has locked falls into the above COPY TO
criteria.
My clients are periodically getting a "File is in use" error when
they run the form in question. Would I still get the error message
if I changed the code to use a SELECT-SQL statement? If I would,
then can anyone advise me of the best way to gather records from a
table which is heavily used throughout the day and frequently being
edited/viewed/locked.
Thanks - Debbie
Debbie
2005-02-01 21:16:17 UTC
Permalink
Hi Dan

Sorry, I just checked the error log and it says the exact error is #108 -
"File is in use by another user." Before I COPY TO (lctemp) blah blah blah
to get my data out of the table (or least ways try to!), I declare a local
variable as follows:

lctemp = SYS(2015)

So, I am just copying the data to a throwaway DBF with a (hopefully) unique
name. At the end of the code, I cleanup by saying DELETE FILE (lctemp) +
".*"

Also, at the time this particular form is being run, there is only one
person running it (she's the only one with an access level high enough to do
so).

Does this added info give you a better clue as to where my code is falling
down?

Thanks - Debbie
Post by Dan Freeman
"You have attempted a USE, DELETE, or RENAME command on a file that is
currently open."
Your COPY TO should be just fine. Obviously it won't pick up unsaved changes
by other users, but it shouldn't throw that particular error because of
record locks.
It sounds like you're hard-coding the destination file name in COPY TO and
someone else already has the previously created file open.
Of course, if you're not getting that EXACT error message, all bets are off.
Add "by another" to the message and you've got an entirely different
situation. <g>
Dan
Post by Debbie
Can someone please tell me what would happen in the following
User1 is viewing/editing a record in a table called "orders" and has
locked the record.
At the same time, User2 runs a form and calls a method which has the
SELECT 0
USE orders SHARED
COPY TO (lctemp) FOR orders.ddateplaced = DATE()
The record that User1 has locked falls into the above COPY TO
criteria.
My clients are periodically getting a "File is in use" error when
they run the form in question. Would I still get the error message
if I changed the code to use a SELECT-SQL statement? If I would,
then can anyone advise me of the best way to gather records from a
table which is heavily used throughout the day and frequently being
edited/viewed/locked.
Thanks - Debbie
Dan Freeman
2005-02-01 22:09:19 UTC
Permalink
OK, that helps. But not much. <g> The help text for that error is the same
as the first one.

Sys(2015) is NOT guaranteed to give you a unique file name. After you've
derived a filename, use FILE() to see if that file already exists.

Dan
Post by Debbie
Hi Dan
Sorry, I just checked the error log and it says the exact error is
#108 - "File is in use by another user." Before I COPY TO (lctemp)
blah blah blah to get my data out of the table (or least ways try
lctemp = SYS(2015)
So, I am just copying the data to a throwaway DBF with a (hopefully)
unique name. At the end of the code, I cleanup by saying DELETE FILE
(lctemp) + ".*"
Also, at the time this particular form is being run, there is only one
person running it (she's the only one with an access level high
enough to do so).
Does this added info give you a better clue as to where my code is
falling down?
Thanks - Debbie
Post by Dan Freeman
"You have attempted a USE, DELETE, or RENAME command on a file that
is currently open."
Your COPY TO should be just fine. Obviously it won't pick up unsaved changes
by other users, but it shouldn't throw that particular error because
of record locks.
It sounds like you're hard-coding the destination file name in COPY
TO and someone else already has the previously created file open.
Of course, if you're not getting that EXACT error message, all bets are off.
Add "by another" to the message and you've got an entirely different
situation. <g>
Dan
Post by Debbie
Can someone please tell me what would happen in the following
User1 is viewing/editing a record in a table called "orders" and has
locked the record.
At the same time, User2 runs a form and calls a method which has the
SELECT 0
USE orders SHARED
COPY TO (lctemp) FOR orders.ddateplaced = DATE()
The record that User1 has locked falls into the above COPY TO criteria.
My clients are periodically getting a "File is in use" error when
they run the form in question. Would I still get the error message
if I changed the code to use a SELECT-SQL statement? If I would,
then can anyone advise me of the best way to gather records from a
table which is heavily used throughout the day and frequently being
edited/viewed/locked.
Thanks - Debbie
Debbie
2005-02-01 22:16:48 UTC
Permalink
I'll go back and take another look at my code. Maybe I'm doing something
stupid but can't see "the wood for the trees"! Just so I'm clear though,
are you saying that any time I'm doing either a COPY TO or using a
SELECT-SQL statement on a table where another user has locked a record that
falls into either my FOR or WHERE clause I will NOT get an error, provided
the rest of what I'm doing is coded correctly?

Sorry to be a pain - Debbie :o)
Post by Dan Freeman
OK, that helps. But not much. <g> The help text for that error is the same
as the first one.
Sys(2015) is NOT guaranteed to give you a unique file name. After you've
derived a filename, use FILE() to see if that file already exists.
Dan
Post by Debbie
Hi Dan
Sorry, I just checked the error log and it says the exact error is
#108 - "File is in use by another user." Before I COPY TO (lctemp)
blah blah blah to get my data out of the table (or least ways try
lctemp = SYS(2015)
So, I am just copying the data to a throwaway DBF with a (hopefully)
unique name. At the end of the code, I cleanup by saying DELETE FILE
(lctemp) + ".*"
Also, at the time this particular form is being run, there is only one
person running it (she's the only one with an access level high
enough to do so).
Does this added info give you a better clue as to where my code is
falling down?
Thanks - Debbie
Post by Dan Freeman
"You have attempted a USE, DELETE, or RENAME command on a file that
is currently open."
Your COPY TO should be just fine. Obviously it won't pick up unsaved changes
by other users, but it shouldn't throw that particular error because
of record locks.
It sounds like you're hard-coding the destination file name in COPY
TO and someone else already has the previously created file open.
Of course, if you're not getting that EXACT error message, all bets are off.
Add "by another" to the message and you've got an entirely different
situation. <g>
Dan
Post by Debbie
Can someone please tell me what would happen in the following
User1 is viewing/editing a record in a table called "orders" and has
locked the record.
At the same time, User2 runs a form and calls a method which has the
SELECT 0
USE orders SHARED
COPY TO (lctemp) FOR orders.ddateplaced = DATE()
The record that User1 has locked falls into the above COPY TO criteria.
My clients are periodically getting a "File is in use" error when
they run the form in question. Would I still get the error message
if I changed the code to use a SELECT-SQL statement? If I would,
then can anyone advise me of the best way to gather records from a
table which is heavily used throughout the day and frequently being
edited/viewed/locked.
Thanks - Debbie
Dan Freeman
2005-02-02 00:13:18 UTC
Permalink
That's correct.
Post by Debbie
I'll go back and take another look at my code. Maybe I'm doing
something stupid but can't see "the wood for the trees"! Just so I'm
clear though, are you saying that any time I'm doing either a COPY TO
or using a SELECT-SQL statement on a table where another user has
locked a record that falls into either my FOR or WHERE clause I will
NOT get an error, provided the rest of what I'm doing is coded
correctly?
Sorry to be a pain - Debbie :o)
Post by Dan Freeman
OK, that helps. But not much. <g> The help text for that error is
the same as the first one.
Sys(2015) is NOT guaranteed to give you a unique file name. After
you've derived a filename, use FILE() to see if that file already
exists.
Dan
Post by Debbie
Hi Dan
Sorry, I just checked the error log and it says the exact error is
#108 - "File is in use by another user." Before I COPY TO (lctemp)
blah blah blah to get my data out of the table (or least ways try
lctemp = SYS(2015)
So, I am just copying the data to a throwaway DBF with a (hopefully)
unique name. At the end of the code, I cleanup by saying DELETE
FILE (lctemp) + ".*"
Also, at the time this particular form is being run, there is only
one person running it (she's the only one with an access level high
enough to do so).
Does this added info give you a better clue as to where my code is
falling down?
Thanks - Debbie
Post by Dan Freeman
"You have attempted a USE, DELETE, or RENAME command on a file that
is currently open."
Your COPY TO should be just fine. Obviously it won't pick up unsaved changes
by other users, but it shouldn't throw that particular error
because of record locks.
It sounds like you're hard-coding the destination file name in COPY
TO and someone else already has the previously created file open.
Of course, if you're not getting that EXACT error message, all bets are off.
Add "by another" to the message and you've got an entirely
different situation. <g>
Dan
Post by Debbie
Can someone please tell me what would happen in the following
User1 is viewing/editing a record in a table called "orders" and
has locked the record.
At the same time, User2 runs a form and calls a method which has
SELECT 0
USE orders SHARED
COPY TO (lctemp) FOR orders.ddateplaced = DATE()
The record that User1 has locked falls into the above COPY TO criteria.
My clients are periodically getting a "File is in use" error when
they run the form in question. Would I still get the error
message if I changed the code to use a SELECT-SQL statement? If
I would, then can anyone advise me of the best way to gather
records from a table which is heavily used throughout the day and
frequently being edited/viewed/locked.
Thanks - Debbie
Debbie
2005-02-02 02:34:24 UTC
Permalink
Thanks Dan!
Post by Dan Freeman
That's correct.
Post by Debbie
I'll go back and take another look at my code. Maybe I'm doing
something stupid but can't see "the wood for the trees"! Just so I'm
clear though, are you saying that any time I'm doing either a COPY TO
or using a SELECT-SQL statement on a table where another user has
locked a record that falls into either my FOR or WHERE clause I will
NOT get an error, provided the rest of what I'm doing is coded
correctly?
Sorry to be a pain - Debbie :o)
Post by Dan Freeman
OK, that helps. But not much. <g> The help text for that error is
the same as the first one.
Sys(2015) is NOT guaranteed to give you a unique file name. After
you've derived a filename, use FILE() to see if that file already
exists.
Dan
Post by Debbie
Hi Dan
Sorry, I just checked the error log and it says the exact error is
#108 - "File is in use by another user." Before I COPY TO (lctemp)
blah blah blah to get my data out of the table (or least ways try
lctemp = SYS(2015)
So, I am just copying the data to a throwaway DBF with a (hopefully)
unique name. At the end of the code, I cleanup by saying DELETE
FILE (lctemp) + ".*"
Also, at the time this particular form is being run, there is only
one person running it (she's the only one with an access level high
enough to do so).
Does this added info give you a better clue as to where my code is
falling down?
Thanks - Debbie
Post by Dan Freeman
"You have attempted a USE, DELETE, or RENAME command on a file that
is currently open."
Your COPY TO should be just fine. Obviously it won't pick up unsaved changes
by other users, but it shouldn't throw that particular error
because of record locks.
It sounds like you're hard-coding the destination file name in COPY
TO and someone else already has the previously created file open.
Of course, if you're not getting that EXACT error message, all bets are off.
Add "by another" to the message and you've got an entirely
different situation. <g>
Dan
Post by Debbie
Can someone please tell me what would happen in the following
User1 is viewing/editing a record in a table called "orders" and
has locked the record.
At the same time, User2 runs a form and calls a method which has
SELECT 0
USE orders SHARED
COPY TO (lctemp) FOR orders.ddateplaced = DATE()
The record that User1 has locked falls into the above COPY TO criteria.
My clients are periodically getting a "File is in use" error when
they run the form in question. Would I still get the error
message if I changed the code to use a SELECT-SQL statement? If
I would, then can anyone advise me of the best way to gather
records from a table which is heavily used throughout the day and
frequently being edited/viewed/locked.
Thanks - Debbie
Debbie
2005-02-02 22:59:22 UTC
Permalink
Hi Dan

Just thought I'd let you know - I figured out what my problem was; I had a
piece of code in the wrong place - SET LOCK ON. Stupid me (it usually
is!!!).

I removed it and now the report works fine.

Debbie :o)
Post by Dan Freeman
That's correct.
Post by Debbie
I'll go back and take another look at my code. Maybe I'm doing
something stupid but can't see "the wood for the trees"! Just so I'm
clear though, are you saying that any time I'm doing either a COPY TO
or using a SELECT-SQL statement on a table where another user has
locked a record that falls into either my FOR or WHERE clause I will
NOT get an error, provided the rest of what I'm doing is coded
correctly?
Sorry to be a pain - Debbie :o)
Post by Dan Freeman
OK, that helps. But not much. <g> The help text for that error is
the same as the first one.
Sys(2015) is NOT guaranteed to give you a unique file name. After
you've derived a filename, use FILE() to see if that file already
exists.
Dan
Post by Debbie
Hi Dan
Sorry, I just checked the error log and it says the exact error is
#108 - "File is in use by another user." Before I COPY TO (lctemp)
blah blah blah to get my data out of the table (or least ways try
lctemp = SYS(2015)
So, I am just copying the data to a throwaway DBF with a (hopefully)
unique name. At the end of the code, I cleanup by saying DELETE
FILE (lctemp) + ".*"
Also, at the time this particular form is being run, there is only
one person running it (she's the only one with an access level high
enough to do so).
Does this added info give you a better clue as to where my code is
falling down?
Thanks - Debbie
Post by Dan Freeman
"You have attempted a USE, DELETE, or RENAME command on a file that
is currently open."
Your COPY TO should be just fine. Obviously it won't pick up unsaved changes
by other users, but it shouldn't throw that particular error
because of record locks.
It sounds like you're hard-coding the destination file name in COPY
TO and someone else already has the previously created file open.
Of course, if you're not getting that EXACT error message, all bets are off.
Add "by another" to the message and you've got an entirely
different situation. <g>
Dan
Post by Debbie
Can someone please tell me what would happen in the following
User1 is viewing/editing a record in a table called "orders" and
has locked the record.
At the same time, User2 runs a form and calls a method which has
SELECT 0
USE orders SHARED
COPY TO (lctemp) FOR orders.ddateplaced = DATE()
The record that User1 has locked falls into the above COPY TO criteria.
My clients are periodically getting a "File is in use" error when
they run the form in question. Would I still get the error
message if I changed the code to use a SELECT-SQL statement? If
I would, then can anyone advise me of the best way to gather
records from a table which is heavily used throughout the day and
frequently being edited/viewed/locked.
Thanks - Debbie
Loading...