Search code examples
databaseintersystems-iris

How can I figure out the name of the database for data in the current InterSystems IRIS Namespace?


InterSystems IRIS namespaces can refer to one database where we have code and data. But in the case of the production deployment, the best practice is to have one database for code and one for data. What is the way to know the NAME of the database for data in the current namespace?


Solution

  • ########## input by Yaron Munz · Nov 14, 2018.

    To get information about a namespace, you may use this code (run it only in the %sys" namespace):

    A property variable is passed by reference (i.e., it has to point at the beginning):

    %SYS> S Status=##Class(Config.Namespaces).Get("user", .Properties)
    
    %SYS> zw Properties
    
    Properties("Globals")="USER"
    Properties("Library")="CACHELIB"
    Properties("Routines")="USER"
    Properties("SysGlobals")="CACHESYS"
    Properties("SysRoutines")="CACHESYS"
    Properties("TempGlobals")="CACHETEMP"
    

    ########## input by John Murray · Nov 14, 2018.

    The GetGlobalDest method of %SYS.Namespace is useful in answering your questions, and it doesn't require a switch to %SYS.

    For #1, ask it where ^ROUTINE is mapped to.
    For #2, don't specify any global name.
    For #3, compare the result for your global with the result for #2.

    I previously wrote about this method here.