Artigo
· jan 4 2min de leitura

Como comparar o conteúdo de duas globais

Rubrica de FAQ do InterSystems

O utilitário ^%GCMP pode ser usado para comparar o conteúdo de dois globals.

Por exemplo, para comparar ^test e ^test nos namespaces USER e SAMPLES, ficaria assim:

No exemplo abaixo, 700 globais idênticas são criadas nos dois namespaces, e o conteúdo de uma delas é alterado para torná-lo o alvo de detecção.
 

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>

Se você quiser comparar entre instâncias em servidores diferentes, em vez de dentro da mesma instância, use o utilitário ^DATACHECK. Para instruções sobre como usar o utilitário ^DATACHECK, consulte o artigo relacionado abaixo:

How to compare multiple globals and routines in two databases

Discussão (0)1
Entre ou crie uma conta para continuar