Skip to main content

How to Compile Namespaces

After an upgrade, you must compile the code in each namespace so that it runs under the new version. If the compiler detects any errors, you may need to recompile one or more times for the compiler to resolve all dependencies. Code and namespace compilation require the %Development_CodeModify:USE privilege.

After your code compiles successfully, you may want to export any updated classes or routines, in case you need to run the upgrade in any additional environments. Importing these classes or routines during future upgrades allows you to update your code quickly, minimizing downtime.

Note:

If you are using a manifest as part of your upgrade process, you can compile your code from within the manifest. See the instructions in the Perform Post-Upgrade Tasks section of the Creating and Using an Installation Manifest appendix of this guide.

Compiling Classes

To compile the classes in all namespaces from the Terminal:

do $system.OBJ.CompileAllNamespaces("u")

To compile the classes in a single namespace from the Terminal:

set $namespace = "<namespace>"
do $system.OBJ.CompileAll("u")

To compile the classes in the %SYS namespace from the Terminal:

set $namespace = "%SYS"
do $system.OBJ.CompileList("%Z*,%z*,Z*,z*,'%ZEN.*,'%ZHS*","up")
Note:

If your namespaces contain mapped classes, include the /mapped qualifier in the call to CompileAllNamespaces() or CompileAll():

do $system.OBJ.CompileAllNamespaces("u /mapped")
do $system.OBJ.CompileAll("u /mapped")

Class compiler version utility

To assist customers in determining which class compiler version a class or classes in a namespace have been compiled with, InterSystems provides two assists

  • Method – $System.OBJ.CompileInfoClass(<classname>)

    This method returns the version of the class compiler used to compile this <classname> and the datetime the class was compiled

  • Query – $System.OBJ.CompileInfo(<sortby>)

    This query generates a report for the current namespace that includes all classes, the version of the compiler used to compile each one, and the datetime each was compiled. The first argument <sortby> may have the following values:

    • 0 – the time the class was compiled

    • 1 – the class name

    • 2 – the version of your product the class was compiled in

Compiling Routines

To compile the routines in all namespaces from the Terminal:

do ##Class(%Routine).CompileAllNamespaces()

To compile the routines in a single namespace from the Terminal:

set $namespace = "<namespace>"
do ##Class(%Routine).CompileAll()

To compile the routines in the %SYS namespace from the Terminal:

set $namespace = "%SYS"
do ##Class(%Routine).CompileList("%Z*,%z*,Z*,z*,'%ZEN.*,'%ZHS*","up")
FeedbackOpens in a new tab