· Dec 28, 2016

Private Property


I read the Cache Documentation where it describes Private Property as below:

Specifies that the property is private. Private properties can only be used by instance methods of this class (or its subclasses).
A private property is not displayed in the catalog information (accessed by using %Library.SQLCatalog) and is not returned by a SELECT * query. However, you can explicitly refer to and use a private property in an SQL query.
Can someone please explain how to explicitly refer or use the private property in an SQL query?
Is there any other way to access any Private properties in SQL query?
Discussion (7)0
Log in or sign up to continue

It will probably be "too basic" for your needs, but I was curious to test this, and got it working with the following class example:

Class Test.PrivateTest Extends (%Persistent, %Populate)
Property Name As %String(POPSPEC = "Name()") [ Required ];
Property NickName As %String(POPSPEC = "Name()") [ Private ];

A "select * from Test.PrivateTest" would only return my "Name" data, while a "select Name,NickName from Test.PrivateTest" returns the private property values too.

Can you get such a basic example working for you too?

If you post your class definition, someone could have some better suggestions/ideas.

My property definition is as below:


Property Active As %Integer [ Calculated, Private, SqlComputeCode = { Set {Active}='$D(^ADZDICT("OS80",1,{HospitalCode},1,{LocationCode},"ACT"))
}, SqlComputed ];


I have a method:

Method ActiveGet() As %Integer

I have to pass.. as my example, expanded with your calculated/private Active property (a simplified version of it), still works as I would expect it to:

Property Name As %String(POPSPEC = "Name()") [ Required ];

Property NickName As %String(POPSPEC = "Name()") [ Private ];

Property Active As %Integer [ Calculated, Private, SqlComputeCode = { Set {Active}=($R(100))}, SqlComputed ];
select Name,NickName,Active from Test.PrivateTest
Name    NickName    Active
Hills,Lawrence B.    Wilson,Barb G.    0
Frost,Brendan H.    Smith,Zoe T.    98
Cooper,Tara C.    Edwards,Mo G.    19
Hanson,Howard H.    Cerri,Buzz X.    74
Hammel,Elmo P.    Klausner,Peter G.    77
Quincy,Robert Q.    Townsend,Alice M.    52