Question Bharathsimha Reddy Jakka · Sep 27, 2021

How to find a global's original namespace ? Potentially mapped from a different namespace

How to find a global's original namespace ? Potentially mapped from a different namespace .

I have a global ^Custom that exists in multiple namespaces but it could mapped from namespace Drone(A) to Launch(B)

Without access to Cache management portal how to find where is my global located using cache code ?

Like if ^Custom == ^[Drone]Custom ??

Product version: Caché 2018.1

Comments

Vitaliy Serdtsev · Sep 28, 2021

See %SYS.GlobalQuery_NameSpaceList().

Example:

<FONT COLOR="#0000ff">select </FONT><FONT COLOR="#008000">Name</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#008000">Location </FONT><FONT COLOR="#000080">from </FONT><FONT COLOR="#008000">%SYS</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#008000">GlobalQuery_NameSpaceList</FONT><FONT COLOR="#000000">(,</FONT><FONT COLOR="#008080">''</FONT><FONT COLOR="#000000">,0,,,1,1)</FONT>
<FONT COLOR="#0000ff">select </FONT><FONT COLOR="#008000">Name</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#008000">Location </FONT><FONT COLOR="#000080">from </FONT><FONT COLOR="#008000">%SYS</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#008000">GlobalQuery_NameSpaceList</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008080">'SAMPLES'</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#008080">''</FONT><FONT COLOR="#000000">,0,,,1,1)</FONT>

0
Julius Kavay · Sep 28, 2021

The %SYS.Namespace class contains the methods, you are looking for.

write ##class(%SYS.Namespace).GetGlobalDest( [namspace], "global") --> DB where the global lies
write ##class(%SYS.Namespace).GetRoutineDest( [namspace], "routine") --> DB where the routine lies
write ##class(%SYS.Namespace).GetPackageDest( [namspace], "package") --> DB where the package lies
0
Alexey Maslov · Sep 28, 2021

Bharathsimha,

your initial question should be reformulated as "how to find global's [main] database" because all namespaces have "equal rights" for any global which is visible from (= mapped to) them.

Julias is quite correct in his answering, but you should take into account that it concerns the global's main database only. If global subscript mapping is used, the full solution to get the list of all databases where the global is partially mapped is a more tricky task. If somebody is interested, I can write about how I solved it once.

0
Bharathsimha Reddy Jakka · Sep 28, 2021

Thank you for the details.. we have only one global that has node specific mapping while most of them are whole globals and the solution suggested above works.

For the single node since our data part varies across namespace it is evident of being sourced locally.

Thank you so much.

0