MultiValue Quick Start Tutorial
Executing a Routine
[Home] [Back] [Next]
InterSystems: The power behind what matters   

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:
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.

Send us comments on this page
Copyright © 1997-2019 InterSystems Corporation, Cambridge, MA