Vitaliy Serdtsev · Nov 17, 2017 go to post

All correctly, this is what I had in mind.

Quote:

The Find Global String page enables you to find a given string in the subscripts1 or in the values2 of selected3 globals.

You can select all the globals of the namespace. In this case, the search will be performed across the database. In the search results you will get including the name of global.

Vitaliy Serdtsev · Dec 5, 2017 go to post

In this case $system.SQL.DATEDIFF is not suitable:

USER><FONT COLOR="#0000ff">w $system</FONT><FONT COLOR="#008080">.SQL</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">DATEDIFF</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008000">"yy"</FONT><FONT COLOR="#000000">, </FONT><FONT COLOR="#0000ff">$zdh</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008000">"30.12.1990"</FONT><FONT COLOR="#000000">,4), </FONT><FONT COLOR="#0000ff">$zdh</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008000">"01.01.1991"</FONT><FONT COLOR="#000000">,4))</FONT>
1

USER><FONT COLOR="#0000ff">w </FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#0000ff">$ZD</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#0000ff">$zdh</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008000">"01.01.1991"</FONT><FONT COLOR="#000000">,4),8)-</FONT><FONT COLOR="#0000ff">$ZD</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#0000ff">$zdh</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008000">"30.12.1990"</FONT><FONT COLOR="#000000">,4),8))\10000</FONT> 0

Vitaliy Serdtsev · Dec 16, 2017 go to post

For better performance you should make a few changes:

  1. add an index on DOB field
  2. rebuild the index and run TuneTable
  3. modify the query
    select DOB from HSAA.Patient
    where
    dob<=dateadd('yy',-13,current_date)
    or dob between
          todate((year(current_date)-13)||'0101','yyyymmdd')
      and todate((year(current_date)-13)||'1231','yyyymmdd')
The result will pleasantly surprise you.
Vitaliy Serdtsev · Dec 26, 2017 go to post

Then this:

<FONT COLOR="#000080">Include </FONT><FONT COLOR="#ff0000">Child

</FONT><FONT COLOR="#000080">Class Macro.Child Extends Macro.Parent </FONT><FONT COLOR="#000000">{

</FONT><FONT COLOR="#000080">ClassMethod </FONT><FONT COLOR="#000000">first() {   </FONT><FONT COLOR="#0000ff">#include </FONT><FONT COLOR="#000000">Child }

</FONT><FONT COLOR="#000080">ClassMethod </FONT><FONT COLOR="#000000">Test() [ </FONT><FONT COLOR="#000080">PlaceAfter </FONT><FONT COLOR="#000000">= first ] {   </FONT><FONT COLOR="#0000ff">write </FONT><FONT COLOR="#008000">"Class: " </FONT><FONT COLOR="#000000">, </FONT><FONT COLOR="#0000ff">$classname</FONT><FONT COLOR="#000000">() , ! , </FONT><FONT COLOR="#008000">"Value: " </FONT><FONT COLOR="#000000">, </FONT><FONT COLOR="#0000ff">$$$name </FONT><FONT COLOR="#000000">}

}</FONT>

or this:
<FONT COLOR="#000080">ClassMethod </FONT><FONT COLOR="#000000">Test()
{
  </FONT><FONT COLOR="#0000ff">#include </FONT><FONT COLOR="#000000">Child
  </FONT><FONT COLOR="#0000ff">write </FONT><FONT COLOR="#008000">"Class: " </FONT><FONT COLOR="#000000">, </FONT><FONT COLOR="#0000ff">$classname</FONT><FONT COLOR="#000000">() , ! , </FONT><FONT COLOR="#008000">"Value: " </FONT><FONT COLOR="#000000">, </FONT><FONT COLOR="#0000ff">$$$name
</FONT><FONT COLOR="#000000">}</FONT>
Vitaliy Serdtsev · Dec 26, 2017 go to post
Class include is not required (and does not seem to affect anything) and can be omitted
Yeah, I just forgot to delete that line.
Vitaliy Serdtsev · Dec 26, 2017 go to post

Here's another way (without PlaceAfter):

<FONT COLOR="#000080">Class Macro.Child Extends Macro.Parent
</FONT><FONT COLOR="#000000">{

</FONT><FONT COLOR="#000080">ClassMethod </FONT><FONT COLOR="#000000">%inc() [ </FONT><FONT COLOR="#000080">Internal</FONT><FONT COLOR="#000000">, </FONT><FONT COLOR="#000080">Private </FONT><FONT COLOR="#000000">] {   </FONT><FONT COLOR="#0000ff">#include </FONT><FONT COLOR="#000000">Child }

</FONT><FONT COLOR="#000080">ClassMethod </FONT><FONT COLOR="#000000">Test() {   </FONT><FONT COLOR="#0000ff">write </FONT><FONT COLOR="#008000">"Class: " </FONT><FONT COLOR="#000000">, </FONT><FONT COLOR="#0000ff">$classname</FONT><FONT COLOR="#000000">() , ! , </FONT><FONT COLOR="#008000">"Value: " </FONT><FONT COLOR="#000000">, </FONT><FONT COLOR="#0000ff">$$$name </FONT><FONT COLOR="#000000">}

}</FONT>

Vitaliy Serdtsev · Dec 28, 2017 go to post

Why so difficult?
This similarly following condition:

<FONT COLOR="#000080">WHERE 
</FONT><FONT COLOR="#000000">(
</FONT><FONT COLOR="#008000">year</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#808000">current_date</FONT><FONT COLOR="#000000">) - </FONT><FONT COLOR="#008000">year</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008000">DOB</FONT><FONT COLOR="#000000">)
) >= 13</FONT>
It Besides above was already indicated, why does not follow to use such a code, for example:
<FONT COLOR="#0000ff">select </FONT><FONT COLOR="#808000">datediff</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#000080">year</FONT><FONT COLOR="#000000">,
</FONT><FONT COLOR="#808000">todate</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#808000">to_char</FONT><FONT COLOR="#000000">({</FONT><FONT COLOR="#000080">d </FONT><FONT COLOR="#008080">'1990-12-31'</FONT><FONT COLOR="#000000">},</FONT><FONT COLOR="#008080">'YYYY'</FONT><FONT COLOR="#000000">)||</FONT><FONT COLOR="#008080">':1'</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#008080">'YYYY:MM'</FONT><FONT COLOR="#000000">), -- birthday
</FONT><FONT COLOR="#808000">todate</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#808000">to_char</FONT><FONT COLOR="#000000">({</FONT><FONT COLOR="#000080">d </FONT><FONT COLOR="#008080">'2003-01-01'</FONT><FONT COLOR="#000000">},</FONT><FONT COLOR="#008080">'YYYY'</FONT><FONT COLOR="#000000">)||</FONT><FONT COLOR="#008080">':1'</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#008080">'YYYY:MM'</FONT><FONT COLOR="#000000">) -- report date
)</FONT>
This gives an incorrect result - 13, although it should be 12.
Vitaliy Serdtsev · Dec 29, 2017 go to post

You are right, the macro $$$NULL present only in %sqlMigration.inc and this is not the file that developers often include to its project.
I prefer to use the macro $$$NULLOREF/$$$NULLOID from %occExtent.inc, which is available by default in the class that inherits from %Library.Base, and for routines is enough to include %systemInclude.inc.

Vitaliy Serdtsev · Mar 3, 2018 go to post

On my desktop quite other results.

  <FONT COLOR="#0000ff">n </FONT><FONT COLOR="#800000">N</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#800000">j</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#800000">time

  </FONT><FONT COLOR="#0000ff">s </FONT><FONT COLOR="#800000">N</FONT><FONT COLOR="#000000">=1e8

  </FONT><FONT COLOR="#0000ff">f </FONT><FONT COLOR="#800000">j</FONT><FONT COLOR="#000000">=1,2</FONT><FONT COLOR="#008000">/,3,4,5/ </FONT><FONT COLOR="#800080">{     </FONT><FONT COLOR="#0000ff">w </FONT><FONT COLOR="#800000">j</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#008000">") "

    </FONT><FONT COLOR="#0000ff">s </FONT><FONT COLOR="#800000">time</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#0000ff">$zh     d </FONT><FONT COLOR="#000000">@(</FONT><FONT COLOR="#008000">"j"</FONT><FONT COLOR="#000000">_</FONT><FONT COLOR="#800000">j</FONT><FONT COLOR="#000000">)(</FONT><FONT COLOR="#800000">N</FONT><FONT COLOR="#000000">)     </FONT><FONT COLOR="#0000ff">w $zh</FONT><FONT COLOR="#000000">-</FONT><FONT COLOR="#800000">time</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#008000">" s."</FONT><FONT COLOR="#000000">,!   </FONT><FONT COLOR="#800080">}   </FONT><FONT COLOR="#0000ff">q </FONT><FONT COLOR="#ff0000">j1</FONT><FONT COLOR="#000000">(N) </FONT><FONT COLOR="#0000ff">public </FONT><FONT COLOR="#800080">{   </FONT><FONT COLOR="#0000ff">f </FONT><FONT COLOR="#800000">i</FONT><FONT COLOR="#000000">=1:1:</FONT><FONT COLOR="#800000">N </FONT><FONT COLOR="#800080">{</FONT><FONT COLOR="#0000ff">s </FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">a</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#800000">b</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#800000">c</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#800000">d</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#800000">e</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#800000">f</FONT><FONT COLOR="#000000">)=0</FONT><FONT COLOR="#800080">} } </FONT><FONT COLOR="#ff0000">j2</FONT><FONT COLOR="#000000">(N) </FONT><FONT COLOR="#0000ff">public </FONT><FONT COLOR="#800080">{   </FONT><FONT COLOR="#0000ff">f </FONT><FONT COLOR="#800000">i</FONT><FONT COLOR="#000000">=1:1:</FONT><FONT COLOR="#800000">N </FONT><FONT COLOR="#800080">{</FONT><FONT COLOR="#0000ff">s </FONT><FONT COLOR="#800000">a</FONT><FONT COLOR="#000000">=0,</FONT><FONT COLOR="#800000">b</FONT><FONT COLOR="#000000">=0,</FONT><FONT COLOR="#800000">c</FONT><FONT COLOR="#000000">=0,</FONT><FONT COLOR="#800000">d</FONT><FONT COLOR="#000000">=0,</FONT><FONT COLOR="#800000">e</FONT><FONT COLOR="#000000">=0,</FONT><FONT COLOR="#800000">f</FONT><FONT COLOR="#000000">=0</FONT><FONT COLOR="#800080">} } </FONT><FONT COLOR="#ff0000">j3</FONT><FONT COLOR="#000000">(N) </FONT><FONT COLOR="#0000ff">public </FONT><FONT COLOR="#800080">{   </FONT><FONT COLOR="#0000ff">f </FONT><FONT COLOR="#800000">i</FONT><FONT COLOR="#000000">=1:1:</FONT><FONT COLOR="#800000">N </FONT><FONT COLOR="#800080">{</FONT><FONT COLOR="#0000ff">s </FONT><FONT COLOR="#800000">a</FONT><FONT COLOR="#000000">=0,</FONT><FONT COLOR="#800000">b</FONT><FONT COLOR="#000000">=1,</FONT><FONT COLOR="#800000">c</FONT><FONT COLOR="#000000">=2,</FONT><FONT COLOR="#800000">d</FONT><FONT COLOR="#000000">=3,</FONT><FONT COLOR="#800000">e</FONT><FONT COLOR="#000000">=4,</FONT><FONT COLOR="#800000">f</FONT><FONT COLOR="#000000">=5</FONT><FONT COLOR="#800080">} } </FONT><FONT COLOR="#ff0000">j4</FONT><FONT COLOR="#000000">(N) </FONT><FONT COLOR="#0000ff">public </FONT><FONT COLOR="#800080">{   </FONT><FONT COLOR="#0000ff">f </FONT><FONT COLOR="#800000">i</FONT><FONT COLOR="#000000">=1:1:</FONT><FONT COLOR="#800000">N </FONT><FONT COLOR="#800080">{</FONT><FONT COLOR="#0000ff">s </FONT><FONT COLOR="#800000">a</FONT><FONT COLOR="#000000">=0 </FONT><FONT COLOR="#0000ff">s </FONT><FONT COLOR="#800000">b</FONT><FONT COLOR="#000000">=1 </FONT><FONT COLOR="#0000ff">s </FONT><FONT COLOR="#800000">c</FONT><FONT COLOR="#000000">=2 </FONT><FONT COLOR="#0000ff">s </FONT><FONT COLOR="#800000">d</FONT><FONT COLOR="#000000">=3 </FONT><FONT COLOR="#0000ff">s </FONT><FONT COLOR="#800000">e</FONT><FONT COLOR="#000000">=4 </FONT><FONT COLOR="#0000ff">s </FONT><FONT COLOR="#800000">f</FONT><FONT COLOR="#000000">=5</FONT><FONT COLOR="#800080">} } </FONT><FONT COLOR="#ff0000">j5</FONT><FONT COLOR="#000000">(N) </FONT><FONT COLOR="#0000ff">public </FONT><FONT COLOR="#800080">{   </FONT><FONT COLOR="#0000ff">f </FONT><FONT COLOR="#800000">i</FONT><FONT COLOR="#000000">=1:1:</FONT><FONT COLOR="#800000">N </FONT><FONT COLOR="#800080">{</FONT><FONT COLOR="#0000ff">s $lb</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">a</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#800000">b</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#800000">c</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#800000">d</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#800000">e</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#800000">f</FONT><FONT COLOR="#000000">)=</FONT><FONT COLOR="#0000ff">$lb</FONT><FONT COLOR="#000000">(0,1,2,3,4,5)</FONT><FONT COLOR="#800080">} }</FONT>

Results:
USER><FONT COLOR="#0000ff">d </FONT><FONT COLOR="#000000">^perf</FONT>
  1. 11.814189 s.
  2. 4.683832 s.
As you can see the difference is almost 2.5 times.
Vitaliy Serdtsev · Mar 5, 2018 go to post

Fixed bugs/typos and added new types.

<FONT COLOR="#0000ff">#include </FONT><FONT COLOR="#000000">%PVA
</FONT><FONT COLOR="#ff0000">types </FONT><FONT COLOR="#008000">; Show COS-Datatypes ; kav ; 2018-03-04
 </FONT><FONT COLOR="#0000ff">n </FONT><FONT COLOR="#800000">array</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#800000">i</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#800000">bitstring
 
 </FONT><FONT COLOR="#0000ff">s $bit</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">bitstring</FONT><FONT COLOR="#000000">,1) = 1

 </FONT><FONT COLOR="#0000ff">w </FONT><FONT COLOR="#008000">"№"</FONT><FONT COLOR="#000000">,?4,</FONT><FONT COLOR="#008000">"VALUE"</FONT><FONT COLOR="#000000">,?30,</FONT><FONT COLOR="#008000">"JSON"</FONT><FONT COLOR="#000000">,?45,</FONT><FONT COLOR="#008000">"$LISTBUILD"</FONT><FONT COLOR="#000000">,!,</FONT><FONT COLOR="#0000ff">$TR</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#0000ff">$J</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008000">""</FONT><FONT COLOR="#000000">,55),</FONT><FONT COLOR="#008000">" "</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#008000">"-"</FONT><FONT COLOR="#000000">),!    </FONT><FONT COLOR="#0000ff">s </FONT><FONT COLOR="#800000">array</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#ff00ff">[           </FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">bitstring</FONT><FONT COLOR="#000000">)</FONT><FONT COLOR="#808080">,           </FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#0000ff">$ZBITSET</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#0000ff">$ZBITSTR</FONT><FONT COLOR="#000000">(4,1),2,0))</FONT><FONT COLOR="#808080">,           </FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#0000ff">$lb</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008000">""</FONT><FONT COLOR="#000000">))</FONT><FONT COLOR="#808080">,           </FONT><FONT COLOR="#0000ff">null</FONT><FONT COLOR="#808080">,           </FONT><FONT COLOR="#0000ff">true</FONT><FONT COLOR="#808080">,           </FONT><FONT COLOR="#0000ff">false</FONT><FONT COLOR="#808080">,           </FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#000080">##class</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008080">%ZEN.proxyObject</FONT><FONT COLOR="#000000">).</FONT><FONT COLOR="#0000ff">%New</FONT><FONT COLOR="#000000">())</FONT><FONT COLOR="#808080">,           </FONT><FONT COLOR="#ff00ff">[]</FONT><FONT COLOR="#808080">,           </FONT><FONT COLOR="#ff00ff">{}</FONT><FONT COLOR="#808080">,           </FONT><FONT COLOR="#008000">"abcd"</FONT><FONT COLOR="#808080">,           </FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#0000ff">$wc</FONT><FONT COLOR="#000000">(35222))</FONT><FONT COLOR="#808080">,           </FONT><FONT COLOR="#008000">"2"</FONT><FONT COLOR="#808080">,           </FONT><FONT COLOR="#000000">2</FONT><FONT COLOR="#808080">,           </FONT><FONT COLOR="#000000">-2</FONT><FONT COLOR="#808080">,           </FONT><FONT COLOR="#000000">2.1</FONT><FONT COLOR="#808080">,           </FONT><FONT COLOR="#000000">-2.1</FONT><FONT COLOR="#808080">,           </FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#0000ff">$double</FONT><FONT COLOR="#000000">(2.1))           </FONT><FONT COLOR="#ff00ff">]  </FONT><FONT COLOR="#0000ff">s </FONT><FONT COLOR="#800000">array</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">"18"</FONT><FONT COLOR="#000000">=2  </FONT><FONT COLOR="#0000ff">s </FONT><FONT COLOR="#800000">array</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">"19"</FONT><FONT COLOR="#000000">=-2             </FONT><FONT COLOR="#0000ff">f </FONT><FONT COLOR="#800000">i</FONT><FONT COLOR="#000000">=0:1:</FONT><FONT COLOR="#800000">array</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">%Size</FONT><FONT COLOR="#000000">() </FONT><FONT COLOR="#800080">{    </FONT><FONT COLOR="#0000ff">w </FONT><FONT COLOR="#800000">i</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#008000">")"</FONT><FONT COLOR="#000000">,?4,</FONT><FONT COLOR="#800000">array</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">%Get</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">i</FONT><FONT COLOR="#000000">),?30,</FONT><FONT COLOR="#0000ff">$$</FONT><FONT COLOR="#ff0000">TypeOf1</FONT><FONT COLOR="#000000">(.</FONT><FONT COLOR="#800000">array</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#800000">i</FONT><FONT COLOR="#000000">),?45,</FONT><FONT COLOR="#0000ff">$$</FONT><FONT COLOR="#ff0000">TypeOf2</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">array</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">%Get</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">i</FONT><FONT COLOR="#000000">)),!  </FONT><FONT COLOR="#800080">}    </FONT><FONT COLOR="#008000">// Return JSON datatype by the documented way  // </FONT><FONT COLOR="#ff0000">TypeOf1</FONT><FONT COLOR="#000000">(&array,key) </FONT><FONT COLOR="#800080">{   </FONT><FONT COLOR="#0000ff">s </FONT><FONT COLOR="#800000">typ</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#800000">array</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">%GetTypeCodeOf</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">key</FONT><FONT COLOR="#000000">)   </FONT><FONT COLOR="#0000ff">q </FONT><FONT COLOR="#800000">typ</FONT><FONT COLOR="#000000"></FONT><FONT COLOR="#008000">" "</FONT><FONT COLOR="#000000"></FONT><FONT COLOR="#0000ff">$case</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">typ</FONT><FONT COLOR="#000000">,     </FONT><FONT COLOR="#0000ff">$$$PVVALUENULL</FONT><FONT COLOR="#000000">:</FONT><FONT COLOR="#008000">"null"</FONT><FONT COLOR="#000000">,     </FONT><FONT COLOR="#0000ff">$$$PVVALUETRUE</FONT><FONT COLOR="#000000">:</FONT><FONT COLOR="#008000">"boolTrue"</FONT><FONT COLOR="#000000">,     </FONT><FONT COLOR="#0000ff">$$$PVVALUEFALSE</FONT><FONT COLOR="#000000">:</FONT><FONT COLOR="#008000">"boolFalse"</FONT><FONT COLOR="#000000">,     </FONT><FONT COLOR="#0000ff">$$$PVVALUEINTEGERPOS</FONT><FONT COLOR="#000000">:</FONT><FONT COLOR="#008000">"+int"</FONT><FONT COLOR="#000000">,     </FONT><FONT COLOR="#0000ff">$$$PVVALUEINTEGERNEG</FONT><FONT COLOR="#000000">:</FONT><FONT COLOR="#008000">"-int"</FONT><FONT COLOR="#000000">,     </FONT><FONT COLOR="#0000ff">$$$PVVALUEUNUSED1</FONT><FONT COLOR="#000000">:</FONT><FONT COLOR="#008000">"unused"</FONT><FONT COLOR="#000000">,     </FONT><FONT COLOR="#0000ff">$$$PVVALUEARRAY</FONT><FONT COLOR="#000000">:</FONT><FONT COLOR="#008000">"array"</FONT><FONT COLOR="#000000">,     </FONT><FONT COLOR="#0000ff">$$$PVVALUEOBJECT</FONT><FONT COLOR="#000000">:</FONT><FONT COLOR="#008000">"object"</FONT><FONT COLOR="#000000">,     </FONT><FONT COLOR="#0000ff">$$$PVVALUETEXT</FONT><FONT COLOR="#000000">:</FONT><FONT COLOR="#008000">"text"</FONT><FONT COLOR="#000000">,     </FONT><FONT COLOR="#0000ff">$$$PVVALUENUMBER</FONT><FONT COLOR="#000000">:</FONT><FONT COLOR="#008000">"number"</FONT><FONT COLOR="#000000">,     </FONT><FONT COLOR="#0000ff">$$$PVVALUEOVERFLOW</FONT><FONT COLOR="#000000">:</FONT><FONT COLOR="#008000">"overflow"</FONT><FONT COLOR="#000000">,     </FONT><FONT COLOR="#0000ff">$$$PVVALUECACHENUMERIC</FONT><FONT COLOR="#000000">:</FONT><FONT COLOR="#008000">"cacheNumeric"</FONT><FONT COLOR="#000000">,     </FONT><FONT COLOR="#0000ff">$$$PVVALUEOREF</FONT><FONT COLOR="#000000">:</FONT><FONT COLOR="#008000">"oref"</FONT><FONT COLOR="#000000">,     </FONT><FONT COLOR="#0000ff">$$$PVVALUEUNASSIGNED</FONT><FONT COLOR="#000000">:</FONT><FONT COLOR="#008000">"unassigned"</FONT><FONT COLOR="#000000">,     </FONT><FONT COLOR="#0000ff">$$$PVVALUELONGPOS</FONT><FONT COLOR="#000000">:</FONT><FONT COLOR="#008000">"+long"</FONT><FONT COLOR="#000000">,     </FONT><FONT COLOR="#0000ff">$$$PVVALUELONGNEG</FONT><FONT COLOR="#000000">:</FONT><FONT COLOR="#008000">"-long"</FONT><FONT COLOR="#000000">,     </FONT><FONT COLOR="#0000ff">$$$PVVALUEBYTE</FONT><FONT COLOR="#000000">:</FONT><FONT COLOR="#008000">"byte[]"</FONT><FONT COLOR="#000000">,     </FONT><FONT COLOR="#0000ff">$$$PVVALUEDATETIME</FONT><FONT COLOR="#000000">:</FONT><FONT COLOR="#008000">"dateTime"</FONT><FONT COLOR="#000000">,     </FONT><FONT COLOR="#0000ff">$$$PVVALUEDOUBLE</FONT><FONT COLOR="#000000">:</FONT><FONT COLOR="#008000">"double"</FONT><FONT COLOR="#000000">,     </FONT><FONT COLOR="#0000ff">$$$PVVALUESINGLE</FONT><FONT COLOR="#000000">:</FONT><FONT COLOR="#008000">"single"</FONT><FONT COLOR="#000000">,     </FONT><FONT COLOR="#0000ff">$$$PVVALUEUTF8</FONT><FONT COLOR="#000000">:</FONT><FONT COLOR="#008000">"utf8"</FONT><FONT COLOR="#000000">,     </FONT><FONT COLOR="#0000ff">$$$PVVALUENESTED</FONT><FONT COLOR="#000000">:</FONT><FONT COLOR="#008000">"nested"</FONT><FONT COLOR="#000000">,     </FONT><FONT COLOR="#0000ff">$$$PVVALUEEOF</FONT><FONT COLOR="#000000">:</FONT><FONT COLOR="#008000">"eof"</FONT><FONT COLOR="#000000">,     :</FONT><FONT COLOR="#008000">"unknown"</FONT><FONT COLOR="#000000">) </FONT><FONT COLOR="#800080">}      </FONT><FONT COLOR="#008000">// Return datatype by the undocumented $LB() way  // </FONT><FONT COLOR="#ff0000">TypeOf2</FONT><FONT COLOR="#000000">(val)  </FONT><FONT COLOR="#800080">{   </FONT><FONT COLOR="#0000ff">i $l</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">val</FONT><FONT COLOR="#000000">)>253 </FONT><FONT COLOR="#800080">{     </FONT><FONT COLOR="#0000ff">s </FONT><FONT COLOR="#800000">typ</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#0000ff">$ziswide</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">val</FONT><FONT COLOR="#000000">)+1   </FONT><FONT COLOR="#800080">} </FONT><FONT COLOR="#0000ff">else </FONT><FONT COLOR="#800080">{     </FONT><FONT COLOR="#0000ff">s </FONT><FONT COLOR="#800000">typ</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#0000ff">$a</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#0000ff">$lb</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">val</FONT><FONT COLOR="#000000">),2)   </FONT><FONT COLOR="#800080">}   </FONT><FONT COLOR="#0000ff">q </FONT><FONT COLOR="#800000">typ</FONT><FONT COLOR="#000000"></FONT><FONT COLOR="#008000">" "</FONT><FONT COLOR="#000000"></FONT><FONT COLOR="#0000ff">$case</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">typ     </FONT><FONT COLOR="#000000">,1:</FONT><FONT COLOR="#008000">"8bitString"     </FONT><FONT COLOR="#000000">,2:</FONT><FONT COLOR="#008000">"16bitString"     </FONT><FONT COLOR="#000000">,4:</FONT><FONT COLOR="#008000">"nonNegativeInteger"     </FONT><FONT COLOR="#000000">,5:</FONT><FONT COLOR="#008000">"negativeInteger"     </FONT><FONT COLOR="#000000">,6:</FONT><FONT COLOR="#008000">"nonNegativeFloat"     </FONT><FONT COLOR="#000000">,7:</FONT><FONT COLOR="#008000">"negativeFloat"     </FONT><FONT COLOR="#000000">,8:</FONT><FONT COLOR="#008000">"double"     </FONT><FONT COLOR="#000000">, :</FONT><FONT COLOR="#008000">"??? never seen before"</FONT><FONT COLOR="#000000">) </FONT><FONT COLOR="#800080">}</FONT>

Result:
USER><FONT COLOR="#0000ff">d </FONT><FONT COLOR="#000000">^types</FONT>
№   VALUE                     JSON           $LISTBUILD
  1. Ÿ 8 text 1 8bitString 8 text 1 8bitString
  2.                        8 text         1 8bitString
    
  3.                        0 null         1 8bitString
    
  4. 1 1 boolTrue 1 8bitString
  5. 0 2 boolFalse 1 8bitString
  6. 4@%ZEN.proxyObject 12 oref 1 8bitString
  7. 2@%Library.DynamicArray 6 array 1 8bitString
  8. 1@%Library.DynamicObject 7 object 1 8bitString
  9. abcd 8 text 1 8bitString
  10. 視 8 text 2 16bitString
  11. 2 8 text 1 8bitString
  12. 2 9 number 4 nonNegativeInteger
  13. -2 9 number 5 negativeInteger
  14. 2.1 9 number 6 nonNegativeFloat
  15. -2.1 9 number 7 negativeFloat
  16. 2.1000000000000000888 18 double 8 double
  17.                       13 unassigned  1 8bitString
    
  18. 2 3 +int 4 nonNegativeInteger
  19. -2 4 -int 5 negativeInteger
  20.                       31 eof         1 8bitString</pre>
    
Vitaliy Serdtsev · Apr 23, 2018 go to post

This can be done also in the CLS.

<FONT COLOR="#ff0000">TEST</FONT><FONT COLOR="#000000">(invar) [outvar] </FONT><FONT COLOR="#0000ff">public </FONT><FONT COLOR="#800080">{

}</FONT>

=>
<FONT COLOR="#000080">ClassMethod </FONT><FONT COLOR="#000000">TEST(</FONT><FONT COLOR="#ff00ff">invar</FONT><FONT COLOR="#000000">) [</FONT><FONT COLOR="#000080">PublicList</FONT><FONT COLOR="#000000">=outvar] {

}</FONT>

PublicList
Vitaliy Serdtsev · Apr 25, 2018 go to post

Still can be so:

<FONT COLOR="#000080">Class dc.test </FONT><FONT COLOR="#000000">[ </FONT><FONT COLOR="#000080">Abstract </FONT><FONT COLOR="#000000">]
{

</FONT><FONT COLOR="#000080">ClassMethod </FONT><FONT COLOR="#000000">Test(</FONT><FONT COLOR="#ff00ff">s </FONT><FONT COLOR="#000000">= </FONT><FONT COLOR="#800080">"#"</FONT><FONT COLOR="#000000">) {   </FONT><FONT COLOR="#0000ff">w </FONT><FONT COLOR="#008000">"Test_"</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#800000">s </FONT><FONT COLOR="#000000">}

</FONT><FONT COLOR="#000080">ClassMethod </FONT><FONT COLOR="#000000">mac() [ </FONT><FONT COLOR="#000080">ProcedureBlock </FONT><FONT COLOR="#000000">= 0 ] { </FONT><FONT COLOR="#ff0000">sub1</FONT><FONT COLOR="#000000">(s=1)   </FONT><FONT COLOR="#0000ff">w </FONT><FONT COLOR="#008000">"sub1_"</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#800000">s   </FONT><FONT COLOR="#0000ff">q </FONT><FONT COLOR="#ff0000">sub2</FONT><FONT COLOR="#000000">(s=2)   </FONT><FONT COLOR="#0000ff">w </FONT><FONT COLOR="#008000">"sub2_"</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#800000">s   </FONT><FONT COLOR="#0000ff">q </FONT><FONT COLOR="#ff0000">procPrivate</FONT><FONT COLOR="#000000">(s=3) </FONT><FONT COLOR="#800080">{   </FONT><FONT COLOR="#0000ff">w </FONT><FONT COLOR="#008000">"procPrivate_"</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#800000">s </FONT><FONT COLOR="#800080">} </FONT><FONT COLOR="#ff0000">procPublic</FONT><FONT COLOR="#000000">(s=3) </FONT><FONT COLOR="#0000ff">public </FONT><FONT COLOR="#800080">{   </FONT><FONT COLOR="#0000ff">w </FONT><FONT COLOR="#008000">"procPublic_"</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#800000">s </FONT><FONT COLOR="#800080">} </FONT><FONT COLOR="#000000">}

}</FONT>

Result:
USER><FONT COLOR="#0000ff">d </FONT><FONT COLOR="#ff0000">zTest</FONT><FONT COLOR="#000000">^dc.test.1(1)</FONT>
Test_1
USER><FONT COLOR="#0000ff">d </FONT><FONT COLOR="#ff0000">sub1</FONT><FONT COLOR="#000000">^dc.test.1</FONT>
sub1_1
USER><FONT COLOR="#0000ff">d </FONT><FONT COLOR="#ff0000">sub2</FONT><FONT COLOR="#000000">^dc.test.1</FONT>
sub2_2
USER><FONT COLOR="#0000ff">d </FONT><FONT COLOR="#ff0000">sub1</FONT><FONT COLOR="#000000">^dc.test.1(10)</FONT>
sub1_10
USER><FONT COLOR="#0000ff">d </FONT><FONT COLOR="#ff0000">sub2</FONT><FONT COLOR="#000000">^dc.test.1(10)</FONT>
sub2_10
USER><FONT COLOR="#0000ff">d </FONT><FONT COLOR="#ff0000">procPrivate</FONT><FONT COLOR="#000000">^dc.test.1(10)</FONT>

D procPrivate^dc.test.1(10) ^ <NOLINE> USER><FONT COLOR="#0000ff">d </FONT><FONT COLOR="#ff0000">procPublic</FONT><FONT COLOR="#000000">^dc.test.1(10)</FONT> procPublic_10 USER>

Vitaliy Serdtsev · May 11, 2018 go to post

You can see the code examples and coding style in the sources of namespaces '%SYS' and/or 'SAMPLES'. But keep in mind that the style of classes written a long time ago differs significantly from style of classes written relatively recently, ex. [$ZT vs try/catch] or [%ResultSet vs %SQL.Statement]

Vitaliy Serdtsev · Jun 4, 2018 go to post

Here is my solution, which has a number of advantages:

  1. there are no restrictions to the order of ID
  2. you can search in queries for the entire timestamp or for parts of it
  3. standard, reliable and proven Caché features are used
  4. this works very, very fast.

See my article for details: Indexing of non-atomic attributes

Class dc.TSOrder Extends (%Persistent%Populate)
{

</FONT><FONT COLOR="#000080">Index </FONT><FONT COLOR="#000000">Extent [ </FONT><FONT COLOR="#000080">Extent</FONT><FONT COLOR="#000000">, </FONT><FONT COLOR="#000080">Type </FONT><FONT COLOR="#000000">= bitmap ];

</FONT><FONT COLOR="#000080">Index </FONT><FONT COLOR="#000000">iSmartTS On (TS(KEYS), TS(ELEMENTS));

</FONT><FONT COLOR="#000080">Index </FONT><FONT COLOR="#000000">iTS On TS;

</FONT><FONT COLOR="#000080">Property </FONT><FONT COLOR="#000000">TS </FONT><FONT COLOR="#000080">As %TimeStamp</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#000080">MAXVAL </FONT><FONT COLOR="#000000">= </FONT><FONT COLOR="#800080">"2016-07-31 23:59:59.999999"</FONT><FONT COLOR="#000000">, </FONT><FONT COLOR="#000080">MINVAL </FONT><FONT COLOR="#000000">= </FONT><FONT COLOR="#800080">"2016-07-01 00:00:00.000000"</FONT><FONT COLOR="#000000">);

</FONT><FONT COLOR="#000080">Property </FONT><FONT COLOR="#000000">Data </FONT><FONT COLOR="#000080">As %String</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#000080">MAXLEN </FONT><FONT COLOR="#000000">= </FONT><FONT COLOR="#000080">200</FONT><FONT COLOR="#000000">, </FONT><FONT COLOR="#000080">MINLEN </FONT><FONT COLOR="#000000">= </FONT><FONT COLOR="#000080">100</FONT><FONT COLOR="#000000">);

</FONT><FONT COLOR="#000080">ClassMethod </FONT><FONT COLOR="#000000">TSBuildValueArray(   </FONT><FONT COLOR="#ff00ff">value</FONT><FONT COLOR="#000000">,   </FONT><FONT COLOR="#000080">ByRef </FONT><FONT COLOR="#ff00ff">array</FONT><FONT COLOR="#000000">) </FONT><FONT COLOR="#000080">As %Status </FONT><FONT COLOR="#000000">{   </FONT><FONT COLOR="#0000ff">i </FONT><FONT COLOR="#800000">value</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"" </FONT><FONT COLOR="#800080">{     </FONT><FONT COLOR="#0000ff">s </FONT><FONT COLOR="#800000">array</FONT><FONT COLOR="#000000">(0)=</FONT><FONT COLOR="#800000">value   </FONT><FONT COLOR="#800080">}</FONT><FONT COLOR="#0000ff">else</FONT><FONT COLOR="#800080">{     </FONT><FONT COLOR="#0000ff">s </FONT><FONT COLOR="#800000">date</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#0000ff">$p</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">value</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#008000">" "</FONT><FONT COLOR="#000000">,1),     </FONT><FONT COLOR="#800000">time</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#0000ff">$p</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">value</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#008000">" "</FONT><FONT COLOR="#000000">,2),     </FONT><FONT COLOR="#800000">array</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008000">"date"</FONT><FONT COLOR="#000000">)=</FONT><FONT COLOR="#800000">date</FONT><FONT COLOR="#000000">,     </FONT><FONT COLOR="#800000">array</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008000">"time"</FONT><FONT COLOR="#000000">)=</FONT><FONT COLOR="#800000">time</FONT><FONT COLOR="#000000">,     </FONT><FONT COLOR="#800000">array</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008000">"ddhh"</FONT><FONT COLOR="#000000">)=</FONT><FONT COLOR="#0000ff">$p</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">date</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#008000">"-"</FONT><FONT COLOR="#000000">,3)</FONT><FONT COLOR="#008000">"-"</FONT><FONT COLOR="#000000"></FONT><FONT COLOR="#0000ff">$p</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">time</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#008000">":"</FONT><FONT COLOR="#000000">,1)   </FONT><FONT COLOR="#800080">}   </FONT><FONT COLOR="#0000ff">q $$$OK </FONT><FONT COLOR="#000000">}

</FONT><FONT COLOR="#000080">/// d ##class(dc.TSOrder).Fill() ClassMethod </FONT><FONT COLOR="#000000">Fill(</FONT><FONT COLOR="#ff00ff">N </FONT><FONT COLOR="#000000">= {30e6}) {   </FONT><FONT COLOR="#0000ff">d </FONT><FONT COLOR="#000000">..</FONT><FONT COLOR="#0000ff">%KillExtent</FONT><FONT COLOR="#000000">(), ..</FONT><FONT COLOR="#0000ff">Populate</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">N</FONT><FONT COLOR="#000000">), </FONT><FONT COLOR="#0000ff">$system</FONT><FONT COLOR="#008080">.SQL</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">TuneTable</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#0000ff">$classname</FONT><FONT COLOR="#000000">(),</FONT><FONT COLOR="#0000ff">$$$YES</FONT><FONT COLOR="#000000">), </FONT><FONT COLOR="#0000ff">$system</FONT><FONT COLOR="#008080">.OBJ</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">Compile</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#0000ff">$classname</FONT><FONT COLOR="#000000">(),</FONT><FONT COLOR="#008000">"cu-d"</FONT><FONT COLOR="#000000">) }

}</FONT>

Results from SMP:

<FONT COLOR="#0000ff">select </FONT><FONT COLOR="#000080">distinct null from </FONT><FONT COLOR="#008000">dc</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#008000">TSOrder </FONT><FONT COLOR="#000080">where </FONT><FONT COLOR="#008000">TS </FONT><FONT COLOR="#000000">between {</FONT><FONT COLOR="#000080">ts </FONT><FONT COLOR="#008080">'2016-07-01 00:00:00.00000'</FONT><FONT COLOR="#000000">} AND {</FONT><FONT COLOR="#000080">ts </FONT><FONT COLOR="#008080">'2016-07-01 23:59:59.999999'</FONT><FONT COLOR="#000000">}</FONT>

Performance: 2.339 seconds 2109755 global references 14768692 lines executed (the number of selected records is 968476, used the normal index)

<FONT COLOR="#0000ff">select </FONT><FONT COLOR="#000080">distinct null from </FONT><FONT COLOR="#008000">dc</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#008000">TSOrder </FONT><FONT COLOR="#000080">where </FONT><FONT COLOR="#000000">for some %element(</FONT><FONT COLOR="#008000">TS</FONT><FONT COLOR="#000000">) (</FONT><FONT COLOR="#008000">%key</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008080">'date' </FONT><FONT COLOR="#000000">and </FONT><FONT COLOR="#008000">%value </FONT><FONT COLOR="#000000">= </FONT><FONT COLOR="#008080">'2016-07-01'</FONT><FONT COLOR="#000000">)</FONT>

Performance: 2.269 seconds 1936962 global references 15496098 lines executed (the number of selected records is 968476, used the "smart" index)

<FONT COLOR="#0000ff">select </FONT><FONT COLOR="#000080">distinct null from </FONT><FONT COLOR="#008000">dc</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#008000">TSOrder </FONT><FONT COLOR="#000080">where </FONT><FONT COLOR="#000000">for some %element(</FONT><FONT COLOR="#008000">TS</FONT><FONT COLOR="#000000">) (</FONT><FONT COLOR="#008000">%key</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008080">'ddhh' </FONT><FONT COLOR="#000000">and </FONT><FONT COLOR="#008000">%value </FONT><FONT COLOR="#000000">= </FONT><FONT COLOR="#008080">'01-13'</FONT><FONT COLOR="#000000">)</FONT>

Performance: 0.096 seconds 80488 global references 644270 lines executed (the number of selected records is 40239, used the "smart" index)

Vitaliy Serdtsev · Jun 13, 2018 go to post

You can change the XSLFO Stylesheet dynamically or statically. See XSLFOSTYLESHEET

So, there is a class-report, for example MyApp.ReportDemo.

Series of steps:
  1. remove option XSLFOSTYLESHEET, if any, and recompile class
  2. generate XSLFO Stylesheet:
    SAMPLES>d $system.OBJ.DisplayError(##class(MyApp.ReportDemo).GenerateToFile($system.CSP.GetFileName($system.CSP.GetDefaultApp($zu(5))_"/MyApp.ReportDemo.xsl"),4))
  3. make changes to MyApp.ReportDemo.xsl
  4. add the parameter XSLFOSTYLESHEET and recompile the class again
    /// If defined, this provides a reference to the external
    /// stylesheet to use in generating the XSL-FO (PDF) report.
    /// If it is not provided, a stylesheet will be generated 
    /// from the ReportDisplay XData block.
    Parameter XSLFOSTYLESHEET As String = "MyApp.ReportDemo.xsl";

Now open the report in your browser/command line/etc. Profit!

Important: if you change something in ReportDisplay, you need to repeat the steps again.

Vitaliy Serdtsev · Jun 14, 2018 go to post

And if so?

Class dc.EmbedObj Extends %SerialObject
{

Property pOID As %ObjectIdentity Private ];

Property As %String;

Property As %String CalculatedSqlComputeCode = {{*}=##class(dc.EmbedObj).Calcb({pOID})}, SqlComputed ];

ClassMethod Calcb(pOIDAs %String
{
  r=""
  q:pOID="" r

  s $lb(id,cls)=$lfs(pOID,"@")

  p=$system.OBJ.OpenId(cls,id)
  q:'$IsObject(pr

  cls="dc.ContainerObj" {
    r="b"_p.Foobar
  }elseif cls="dc.blablablaContainerObj" {
    r="b"_p.qwe
  }
  r
}
}Class dc.ContainerObj Extends %Persistent
{

Property Foobar As %String;

Property InnerObj As dc.EmbedObj;

Trigger NewTrigger1 [ Event = INSERT, Foreach = row/object, Time = AFTER ]
{
  oid
  oid={%%ID}_"@"_{%%CLASSNAMEQ}
  &sql(update dc.ContainerObj set InnerObj_pOID=:oid where %ID=:{id})
}

/// d ##class(dc.ContainerObj).Test()
ClassMethod Test()
{
  ..%KillExtent()
  
  t=..%New()
  t.Foobar="foobar1"
  t.InnerObj.a="a1"
  t.%Save()

  &sql(insert into dc.ContainerObj(Foobar,InnerObj_avalues('foobar2','a2'))
  
  ##class(%SQL.Statement).%ExecDirect(,"select * from dc.ContainerObj").%Display()
}
}
Vitaliy Serdtsev · Jul 17, 2018 go to post

Use %MVR

For example:
Class dc.test Extends %Persistent
{

</FONT><FONT COLOR="#000080">Index </FONT><FONT COLOR="#000000">ibar On bar;

</FONT><FONT COLOR="#000080">Property </FONT><FONT COLOR="#000000">bar </FONT><FONT COLOR="#000080">As %String</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#000080">COLLATION </FONT><FONT COLOR="#000000">= </FONT><FONT COLOR="#800080">"MVR"</FONT><FONT COLOR="#000000">);

</FONT><FONT COLOR="#000080">ClassMethod </FONT><FONT COLOR="#000000">Test() {   </FONT><FONT COLOR="#0000ff">d </FONT><FONT COLOR="#000000">..</FONT><FONT COLOR="#0000ff">%KillExtent</FONT><FONT COLOR="#000000">()   </FONT><FONT COLOR="#800080">&sql(</FONT><FONT COLOR="#0000ff">insert </FONT><FONT COLOR="#000080">into </FONT><FONT COLOR="#008000">dc</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#008000">test</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008000">bar</FONT><FONT COLOR="#000000">)   </FONT><FONT COLOR="#0000ff">select </FONT><FONT COLOR="#008080">'00123AB' </FONT><FONT COLOR="#000080">union   </FONT><FONT COLOR="#0000ff">select </FONT><FONT COLOR="#008080">'12345AB'</FONT><FONT COLOR="#800080">)

  </FONT><FONT COLOR="#0000ff">d $system</FONT><FONT COLOR="#008080">.SQL</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">TuneTable</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#0000ff">$classname</FONT><FONT COLOR="#000000">(),</FONT><FONT COLOR="#0000ff">$$$YES</FONT><FONT COLOR="#000000">), </FONT><FONT COLOR="#0000ff">$system</FONT><FONT COLOR="#008080">.OBJ</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">Compile</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#0000ff">$classname</FONT><FONT COLOR="#000000">(),</FONT><FONT COLOR="#008000">"cu-d"</FONT><FONT COLOR="#000000">)   </FONT><FONT COLOR="#0000ff">f </FONT><FONT COLOR="#800000">args</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"00123AB"</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#008000">"123AB" </FONT><FONT COLOR="#0000ff">d </FONT><FONT COLOR="#000080">##class</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008080">%SQL.Statement</FONT><FONT COLOR="#000000">).</FONT><FONT COLOR="#0000ff">%ExecDirect</FONT><FONT COLOR="#000000">(,</FONT><FONT COLOR="#008000">"select * from dc.test where bar=?"</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#800000">args</FONT><FONT COLOR="#000000">).</FONT><FONT COLOR="#0000ff">%Display</FONT><FONT COLOR="#000000">() </FONT><FONT COLOR="#0000ff">w </FONT><FONT COLOR="#000000">!! }

}</FONT>

Result:
USER><FONT COLOR="#0000ff">d </FONT><FONT COLOR="#000080">##class</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008080">dc.test</FONT><FONT COLOR="#000000">).</FONT><FONT COLOR="#0000ff">Test</FONT><FONT COLOR="#000000">()</FONT>
ID      bar
1       00123AB

1 Rows(s) Affected

ID bar 1 00123AB

1 Rows(s) Affected