☜ | TSTARTM[UMPS] by Example | ☞ |
Introduced in the 1995 ANSI M[UMPS] language standard.
Clarification (no change intended) in a future M[UMPS] language standard:
Any keywords in the argument of the command are processed in strict left-to-right order. When multiple equivalent parameters are encountered, the last occurrence processed will define the action(s) to be taken.
TStart
():(SERIAL:TRANSACTIONID="DEMO")
TStart *
TStart
(CUSTOMER,COUNT,TOTAL):TRANSACTIONID="NEXT"
TStart CUSTOMER
TStart CUSTOMER:SERIAL
Assume that, initially:
^A = 1
^B = 2
^C(2,1)="XYZ"
^D is not defined
The effect of:
TStart
Lock (^A,^B,^C,^D)
Set ^A=^A+1
Set ^B=^A+2
Kill ^C
Set ^D=5
Lock
TCommit
will be that:
^A = 2
^B = 4
^C is not defined
^D = 5
If ^C had many descendants, the Kill command might exceed the transaction size limitation. In this example, however, this limit is not even approached.
Assuming the same initial conditions, the effect of:
TStart
Lock (^A,^B,^C,^D)
Set ^A=^A+1
Set ^B=^A+2
Kill ^C
Set ^D=5
TROllback
will be that the database contains the original values of all
four global variables.
Note that either a TCommit or a TROllback command is required, and that, in the absence of a TCommit command, a TROllback will be assumed.
Assuming the same initial conditions, the effect of:
TStart
Lock (^A,^B,^C,^D)
Set ^A=^A+1
Set ^B=^A+2
Kill ^C
Set ^D=5
Halt
will be that the database contains the original values of all
four global variables.
Assume that, initially:
^A = 1
^B = 2
^C(2,1)="XYZ"
^D is not defined
X = 15
Y = 27
The effect of:
TStart (X,Y)
Lock (^A,^B)
Set ^A=^A+1,X=X*^A
Set ^B=^A+2,Y=Y–10-^B
Lock (^C,^D):2
If '$Test TREstart
Kill ^C
Set ^D=4
TROllback
will be that the database contains the original values of all
four global variables. In addition, the values of X and
Y will be reset to their original values. If, during
this process, it is not possible to obtain a lock on the names
^C and ^D within the time allotted (2 seconds),
the transaction is restarted, i.e. both global variables that
could have been modified at that point, as well as both local
variables are reset to their original status. There is no limit
to the number of times that the transaction could be
restarted.
In the case of
TStart ():SERIAL
Set FATAL=$TRestart>5
If FATAL Write !,"Failed to update..."
If FATAL TROllback Quit
Set (COUNT,^A(0))=^A(0)+1,^A(COUNT)=X
TCommit
there is a maximum to the number of restarts... Even if the
restart is implicit in the transaction definition.
TStart ; Restart not permitted
TStart () ; Restart permitted, no local variables
protected
TStart A ; Restart permitted, local variable
A protected
TStart (A,B) ; Restart permitted, local variables
A and B protected
TStart * ; Restart permitted, all local variables
protected
TStart ():SERIAL ; Restart permitted, no
local variables protected
; Serializability ensured without explicit Lock
commands
TStart *:SERIAL ; Restart permitted, all
local variables protected
; Serializability ensured witough explicit Lock
commands
Copyright © Standard Documents; 1977-2024 MUMPS Development Committee;
Copyright © Examples: 1995-2024 Ed de Moel;
Copyright © Annotations: 2003-2008 Jacquard Systems Research
Copyright © Annotations: 2008-2024 Ed de Moel.
The information in this page is
NOT authoritative and subject to be modified
at any moment.
Please consult the
appropriate (draft) language standard for an
authoritative definition.
Some specifications are "approved for inclusion in a future standard". Note that the MUMPS Development Committee cannot guarantee that such future standards will indeed be published.
This page most recently updated on 15-Nov-2023, 18:56:29.
For comments, contact Ed de Moel (demoel@jacquardsystems.com)