Private Property

Beginner, Caché

Hello,

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?
 
Thanks,
Aditi
  • 0
  • 0
  • 339
  • 6
  • 1

Answers

All you need to do is, to specify the property name/sql field name  in the select-list of your query.

Thank you! Can you please explain providing an example, that would really help!

Let me add some more details here.

I have a class where I have a private property "Active"

I also tried a simple query "Select Active from classname" and it does not print any data for this property in the result

Also using it in WHERE clause does not return any data.

 

 

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
{
 '$D(^ADZDICT("OS80",1,..HospitalCode,1,..LocationCode,"ACT"))
}

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