Skip to main content

This is documentation for Caché & Ensemble. See the InterSystems IRIS version of this content.

For information on migrating to InterSystems IRIS, see Why Migrate to InterSystems IRIS?

Executing a Routine

Java projections can also be used to execute basic routines. For example, MyAccount contains the GETVALUE routine. The routine accepts a record ID, an attribute name, and a value number as arguments. It returns the corresponding piece of multivalue data. Here are the steps for executing this routine from Java:

  1. Create a Caché class and add a method, like the following, that wraps a call to the MVBasic routine. Note that the Caché class need not be persistent. It holds no data. It can extend %RegisteredObject.

    ClassMethod GetValue(ID As %String, ATTRNAME As %String, VNO As %String) 
     As %String
  2. Create a Java projection for the Caché class.

  3. Execute the routine from the Java code using the projection. Here is example Java code:

    String value = Search.GetValue(db, "3", "NAME","1");
    System.out.printf("Value: %s", value);

    Note the following about these lines of Java code:

    • Search is the Java projection for the Caché class containing GetValue.

    • The Caché GetValue method is a Class Method, which projects to a Java static method. No instance of Search is required to execute it.

    • The db variable represents an open CacheDatabase object.


The above Caché GetValue method is in MVExample.Search, which is contained in MVExample.xml. The above Java code is contained in Both files are in <cachesys>\Dev\tutorials\mv. Importing a File Using Studio contains step-by-step instructions for importing and installing Caché code. Executing the Java Examples contains step-by-step instructions for executing the Java code.