Using Caché Objects - InterSystems Documentation
Using Caché Objects - InterSystems Documentation
Using Caché Objects - InterSystems Documentation
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
<strong>Objects</strong> and SQL<br />
The way to determine if a field is Always Computed or Triggered Computed is by the<br />
TRANSIENT and/or CALCULATED property keywords. If the property is transient or calculated,<br />
and has SQLCOMPUTED, the compute type is Always. If the property is not transient, not<br />
calculated, and has SQLCOMPUTED, the compute type is Triggered.<br />
An Example<br />
Suppose a class has a Name property of the form last,first. You might use the value stored<br />
in this property to create the calculated fields FirstName and LastName (each containing the<br />
first and last name, respectively). To do this, the code to set the value of the computed<br />
LastName field would be:<br />
Set {LastName}=##class(MyClass).GetLastName({Name})<br />
where MyClass is the class being projected and GetLastName is a class method which has<br />
the following code in it:<br />
Quit $Piece(Name,",")<br />
This code simply returns the first element in the Name property that appears before the “,”<br />
delimiter.<br />
13.2.3 Methods<br />
A class' instance methods are only accessible via the object representation of a class, and not<br />
via SQL. This is because an SQL query does not cause objects to be instantiated their (hence,<br />
their methods are not accessible).<br />
13.2.4 SQL Triggers<br />
Because <strong>Caché</strong> SQL supports the use of triggers, any trigger associated with a class is included<br />
as part of the class' SQL projection.<br />
For more information on triggers, see the section Triggers in <strong>Using</strong> <strong>Caché</strong> SQL.<br />
Triggers are code segments executed when specific events occur in <strong>Caché</strong> SQL. <strong>Caché</strong> supports<br />
triggers based on the execution of INSERT, UPDATE, and DELETE commands. The<br />
specified code will be executed either immediately before or immediately after the relevant<br />
command is executed, depending on the trigger definition. Each event can have multiple<br />
triggers as long as they are assigned an execution order.<br />
Triggers are not fired by the persistence methods used by the default storage class,<br />
%CacheStorage.<br />
122 <strong>Using</strong> <strong>Caché</strong> <strong>Objects</strong>