11.07.2015 Views

Caché ObjectScript Reference - InterSystems Documentation

Caché ObjectScript Reference - InterSystems Documentation

Caché ObjectScript Reference - InterSystems Documentation

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

The following example tests for the existence of a lock name in the current namespace. Thefirst WRITE returns 10 (lock name exists), the second WRITE returns 0 (lock name does notexist):LOCK ^B(1,2) ; define lockWRITE !,$DATA(^$LOCK("^B(1,2)"))LOCK -^B(1,2) ; delete lockWRITE !,$DATA(^$LOCK("^B(1,2)"))As an Argument to $ORDER$ORDER(^$|nspace|LOCK(lock_name),direction)^$LOCK as an argument to $ORDER returns the next or previous ^$LOCK lock namenode in collating sequence to the lock name you specify. If no such lock name exists as a^$LOCK node, $ORDER returns a null string.The direction argument specifies whether to return the next or the previous lock name. If youdo not provide a direction argument, <strong>Caché</strong> returns the next lock name in collating sequenceto the one you specify. For further details, refer to the $ORDER function.The following subroutine searches the locks in the SAMPLES namespace and stores the locknames in a local array named LOCKET.LOCKARRAYSET lname=""FOR I=1:1 {SET lname=$ORDER(^$|"SAMPLES"|LOCK(lname))QUIT:lname=""SET LOCKET(I)=lnameWRITE !,"the lock name is: ",lname}WRITE !,"All lock names listed"QUITAs an Argument to $QUERY$QUERY(^$|nspace|LOCK(lock_name))^$LOCK as an argument to $QUERY returns the next lock name in collating sequence tothe lock name you specify. If there is no next lock name defined as a node in ^$LOCK,$QUERY returns a null string.In the following example, five global lock names are created (in random order) in the currentnamespace.LOCK (^B(1),^A,^D,^A(1,2,3),^A(1,2))WRITE !,"lock name: ",$QUERY(^$LOCK(""))WRITE !,"lock name: ",$QUERY(^$LOCK("^C"))WRITE !,"lock name: ",$QUERY(^$LOCK("^A(1,2)"))^$LOCK<strong>Caché</strong> <strong>ObjectScript</strong> <strong>Reference</strong> 509

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!