25.01.2015 Views

Using Caché Multi-Dimensional Storage - InterSystems ...

Using Caché Multi-Dimensional Storage - InterSystems ...

Using Caché Multi-Dimensional Storage - InterSystems ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Managing Transactions<br />

// Erase any existing data<br />

Kill ^Data<br />

// Set var to an global reference expression<br />

Set var = "^Data(100)"<br />

// Now use indirection to set ^Data(100)<br />

Set @var = "This data was set indirectly."<br />

// Now display the value directly:<br />

Write "Value: ",^Data(100)<br />

You can also use subscript indirection to mix expressions (variables or literal values) within<br />

indirect statements:<br />

// Erase any existing data<br />

Kill ^Data<br />

// Set var to a subscript value<br />

Set glvn = "^Data"<br />

// Now use indirection to set ^Data(1) to ^Data(10)<br />

For i = 1:1:10 {<br />

Set @glvn@(i) = "This data was set indirectly."<br />

}<br />

// Now display the values directly:<br />

Set key = $Order(^Data(""))<br />

While (key '= "") {<br />

Write "Value ",key, ": ", ^Data(key),!<br />

Set key = $Order(^Data(key))<br />

}<br />

Indirection is a fundamental feature of <strong>Caché</strong> ObjectScript; it is not limited to global references.<br />

For more direct information, you can refer to the “Indirection” section in the “Operators”<br />

chapter of <strong>Using</strong> <strong>Caché</strong> ObjectScript. Indirection is less efficient than direct access, so you<br />

should use it judiciously.<br />

3.11 Managing Transactions<br />

<strong>Caché</strong> provides the primitive operations needed to implement full transaction processing<br />

using globals. <strong>Caché</strong> Objects and SQL make use of these features automatically. If you are<br />

directly writing transactional data into globals you can make use of these operations.<br />

The transaction commands are TSTART, which defines the start of a transaction; TCOMMIT,<br />

which commits the current transaction; and TROLLBACK, which aborts the current transaction<br />

and undoes any changes made to globals since the start of the transaction.<br />

<strong>Using</strong> <strong>Caché</strong> <strong>Multi</strong>-<strong>Dimensional</strong> <strong>Storage</strong> 29

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!