Chuck,
You and Chip were actually close. The issue wasn't with the table being in
read only but rather the way I was dealing with loading the record if it
was 'locked'.
"If Locked returns TRUE, then the record cannot be saved because
- it is locked by another user
- another process
- it is stacked in the current process"
I seem to be hitting on #3 - it's stacked (though not sure how but that's
not the point here). My method actually attempted to deal with this by
calling LOAD RECORD but it did it in a complicated way (I wrote this method
a long time ago) and it didn't seem to be working in this case.
I simplified the locking method and this appears to have resolved the
issue. Here's the new code:
// $1 = ptr to table
$isLocked:=Locked($1->)
If ($isLocked) // try loading the record & test again
LOAD RECORD($1->)
$isLocked:=Locked($1->)
End if
Case of
: (Count parameters<2)
//
: (Not($isLocked))
$text:=""
Else // evaluate the locked record
LOCKED BY($1->;$process;$4Duser;$machineName;$p_Name)
PROCESS
PROPERTIES($process;$processName;$procState;$procTime;$procVisible;$uniqueID;$origin)
$text:="["+Table name($1)+"] is locked.\r"+\
"It's locked by "+$4dUser+".\r\r"+\
" Machine : "+$machineName+"\r\r"+("-"*20)+"\r"+\
" Process : "+$p_Name+"\r"+\
" Proc # : "+String($process)+"\r"+\
" Alt name : "+$processName
$2->:=$text
End case //$process=-1
// --------------------------------------------------------
$0:=$isLocked
I verified the code that brought this up would first get Locked=true but
after calling LOAD RECORD Locked=false.
I still think LOCKED BY should return the process info where the record is
stacked but I suppose there could be a number of processes doing that so
it's perhaps not germane.
I appreciate being able to talk this one out.
On Thu, Oct 11, 2018 at 1:31 PM Charles Miller via 4D_Tech <
[email protected]> wrote:
> OK here goes. Given the following code
> You will see that
> $proc=0
> and
> $user,$session,$name are all blank
>
> *READ ONLY*([Table])
>
> *Get a record*
>
> *FIRST RECORD*([Part])
>
> *LOAD RECORD*([Part])
>
> *If *(*Locked*([Part])
>
> *C_LONGINT*($proc)
>
> *c_text*($user;$session;$name)
>
> *LOCKED BY*([Part];$proc;$user;$session;$name)
>
>
>
>
> *end if*
>
>
> On Thu, Oct 11, 2018 at 4:18 PM Kirk Brooks via 4D_Tech <
> [email protected]> wrote:
>
> > Chuck,
> > Well that supposes that the Locked command is not accurate. If that's
> wrong
> > I'm not sure how to prove that. And that would be a much more profound
> > problem, I think. But perhaps. I'm just assuming the issue is with the
> > Locked By command.
> >
> > To be clear my method tests for Locked first:
> >
> > Case of
> >
> > :() // some other stuff to validate the pointer
> >
> > :(Locked($table_p->))
> >
> > // do the locked record stuff
> >
> > End case
> >
> >
> > Sure I can manipulate the records between locked and unlocked. The thing
> is
> > when I do those sorts of operations everything behaves as expected. This
> is
> > some sort of edge case, I just want to understand what the edge is.
> >
> > On Thu, Oct 11, 2018 at 11:14 AM Chuck Miller via 4D_Tech <
> > [email protected]> wrote:
> >
> > > Kirk
> > >
> > > In 15 I had found you could lock records think you unlocked them and
> then
> > > unloaded but they would remain locked until you quit server. What
> happens
> > > in your car if you select a different record. Do both show as locked
> only
> > > first or only the second
> > >
> > > Regards
> > > Chuck
> > >
> > > Sent from my iPhone
> > >
> > > > On Oct 11, 2018, at 1:48 PM, Kirk Brooks via 4D_Tech <
> > > [email protected]> wrote:
> > > >
> > > > I have a method that tests if a record is locked and if it is
> attempts
> > to
> > > > figure out by whom:
> > > >
> > > > $text:="["+Table name($1)+"] "
> > > >
> > > > LOCKED BY($1->;$process;$4Duser;$machineName;$p_Name)
> > > > PROCESS
> > > >
> > >
> >
> PROPERTIES($process;$processName;$procState;$procTime;$procVisible;$uniqueID;$origin)
> > > >
> > > > Case of
> > > > : ($process=-1)
> > > >
> > > > $text:=$text+"The record has been deleted."
> > > >
> > > > : ($process=0)
> > > >
> > > > $text:=$text+" is locked but there is no information available about
> > who
> > > > has it."
> > > >
> > > > Else
> > > >
> > > > $text:=$text+\
> > > >
> > > > "Record number "+String(Record number($1->))+" is locked.\r"+\
> > > >
> > > > "It's open by "+$4dUser+".\r\r"+\
> > > >
> > > > " Process : "+$p_Name+"\r"+\
> > > >
> > > > " Machine : "+$machineName+"\r\r"+("-"*20)+"\r"+\
> > > >
> > > > " Proc # : "+String($process)+"\r"+\
> > > >
> > > > " Alt name : "+$processName
> > > >
> > > > End case
> > > >
> > > >
> > > > I've been using this for years. Recently I noticed (but it may have
> > been
> > > > going on for a while) records will return true for locked but LOCKED
> BY
> > > > doesn't have any process associated with it. The only way I've been
> > able
> > > to
> > > > recreate this is to open a record in User Mode and attempt to load
> the
> > > > record from another process. This works as expected. Then if I close
> > the
> > > > record in User and click off of it to deselect attempting to load
> from
> > > > another process shows the record locked but no info.
> > > >
> > > > It also occurs other times though I haven't been able to replicate
> it.
> > > > Regardless, what to do?
> > > >
> > > > This is v15 running on Mac Mojave so there is all sorts of
> > possibilities
> > > > for weirdness there. Wondering if anyone else has come across this?
> > > >
> > > > --
> > > > Kirk Brooks
> > > > San Francisco, CA
> > > > =======================
> > > >
> > > > *We go vote - they go home*
> > > >
> **********************************************************************
> > > > 4D Internet Users Group (4D iNUG)
> > > > Archive: http://lists.4d.com/archives.html
> > > > Options: https://lists.4d.com/mailman/options/4d_tech
> > > > Unsub: mailto:[email protected]
> > > >
> **********************************************************************
> > >
> > > **********************************************************************
> > > 4D Internet Users Group (4D iNUG)
> > > Archive: http://lists.4d.com/archives.html
> > > Options: https://lists.4d.com/mailman/options/4d_tech
> > > Unsub: mailto:[email protected]
> > > **********************************************************************
> >
> >
> >
> > --
> > Kirk Brooks
> > San Francisco, CA
> > =======================
> >
> > *We go vote - they go home*
> > **********************************************************************
> > 4D Internet Users Group (4D iNUG)
> > Archive: http://lists.4d.com/archives.html
> > Options: https://lists.4d.com/mailman/options/4d_tech
> > Unsub: mailto:[email protected]
> > **********************************************************************
>
>
>
> --
>
> -----------------------------------------------------------------------------------------
> Chuck Miller Voice: (617) 739-0306 Fax: (617) 232-1064
> Informed Solutions, Inc.
> Brookline, MA 02446 USA Registered 4D Developer
> Providers of 4D, Sybase & SQL Server connectivity
> http://www.informed-solutions.com
>
> -----------------------------------------------------------------------------------------
> This message and any attached documents contain information which may be
> confidential, subject to privilege or exempt from disclosure under
> applicable law. These materials are intended only for the use of the
> intended recipient. If you are not the intended recipient of this
> transmission, you are hereby notified that any distribution, disclosure,
> printing, copying, storage, modification or the taking of any action in
> reliance upon this transmission is strictly prohibited. Delivery of this
> message to any person other than the intended recipient shall not
> compromise or waive such confidentiality, privilege or exemption
> from disclosure as to this communication.
> **********************************************************************
> 4D Internet Users Group (4D iNUG)
> Archive: http://lists.4d.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub: mailto:[email protected]
> **********************************************************************
--
Kirk Brooks
San Francisco, CA
=======================
*We go vote - they go home*
**********************************************************************
4D Internet Users Group (4D iNUG)
Archive: http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:[email protected]
**********************************************************************