Article
· 15 hr ago 2m read

How to compare the contents of two globals

InterSystems FAQ rubric

The ^%GCMP utility can be used to compare the contents of two globals.

For example, to compare ^test and ^test in the USER and SAMPLES namespaces, it would look like this:
*In the example below, 700 identical globals are created in the two namespaces, and the contents of one of them is changed to make it the detection target.

USER>kill ^test
USER>for i=1:1:100 { for j=1:1:7 { set ^test(i,j)="Test"_i } }
 
USER>zn "samples"                  // change namespace to SAMPLES
SAMPLES>kill ^test
SAMPLES>for i=1:1:100 { for j=1:1:7 { set ^test(i,j)="Test"_i } }
 
SAMPLES>set ^test(50,5,1)=1        // Change one of the globals created in the SAMPLES namespace.
SAMPLES>do ^%GCMP
Compare global ^test               // Global to compare.
on directory set: (this system)    // Enter
in namespace: SAMPLES =>           // Enter (if this namespace is OK)
with global ^test=>                // Global to compare
on directory set: (this system)    // Enter
in namespace: SAMPLES => USER      // Namespace to compare
Output differences on
Device:                            // Destination for output results. Press <Enter> to view in a terminal.
                                   // If you enter the full path of the log file name, the output will be sent there.
Right margin: 80 =>

Compare global ^test in SAMPLES
 with global ^test in USER
 
^test(50,5,1) exists in ^|"SAMPLES"|test but not in ^|"USER"|test    // Detects differing globals
Time=.001822
SAMPLES>

If you want to compare between instances on different servers, rather than within the same instance, use the ^DATACHECK utility. For instructions on how to use the ^DATACHECK utility, see the related article below:

How to compare multiple globals and routines in two databases

Discussion (0)0
Log in or sign up to continue