Skip to main content

A Look at Stored Data

A Look at Stored Data

This section demonstrates that for any persistent object, the same values are visible via object access, SQL access, and direct global access.

In our IDE, if we view the Sample.Person class, we see the following property definitions:

/// Person's name.
Property Name As %String(POPSPEC = "Name()") [ Required ];

...

/// Person's age.<br> 
/// This is a calculated field whose value is derived from <property>DOB</property>. 
Property Age As %Integer [ details removed for this example ]; 

/// Person's Date of Birth.
Property DOB As %Date(POPSPEC = "Date()");

In the Terminal, we can open a stored object and write its property values:

SAMPLES>set person=##class(Sample.Person).%OpenId(1)
 
SAMPLES>w person.Name
Newton,Dave R.
SAMPLES>w person.Age
21
SAMPLES>w person.DOB
58153
>>> person=iris.cls("Sample.Person")._OpenId(1)
>>> print(person.Name)
Newton, Dave R.
>>> print(person.Age)
21
>>> print(person.DOB)
58153

Note that here we see the literal, stored value of the DOB property. We could instead call a method to return the display value of this property:

SAMPLES>write person.DOBLogicalToDisplay(person.DOB)
03/20/2000
>>> print(iris.cls("%Date").LogicalToDisplay(person.DOB))
03/20/2000

In the Management Portal, we can browse the stored data for this class, which looks as follows:

The stored data for Sample.Person displayed in table form, with the contents displayed row by row.

Notice that in this case, we see the display value for the DOB property. (In the Portal, there is another option to execute queries, and with that option you can control whether to use logical or display mode for the results.)

In the Portal, we can also browse the global that contains the data for this class:

The stored data for Sample.Person as it is stored in the global, with the contents displayed node by node.

Or, in the Terminal, we can write the value of the global node that contains this instance using ObjectScript:

zwrite ^Sample.PersonD("1")
^Sample.PersonD(1)=$lb("","Newton,Dave R.","384-10-6538",58153,$lb("6977 First Street","Pueblo","AK",63163),
$lb("9984 Second Blvd","Washington","MN",42829),"",$lb("Red"))

For reasons of space, the last example contains an added line break.

FeedbackOpens in a new tab