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

Vitaliy Serdtsev · Jul 17, 2018 go to post

test.mac:

<FONT COLOR="#0000ff">#include </FONT><FONT COLOR="#000000">%systemInclude

  </FONT><FONT COLOR="#0000ff">#define </FONT><FONT COLOR="#000000">getServState(%serviceName) </FONT><FONT COLOR="#0000ff">##class(%Activate.GenericObject).GetObject(</FONT><FONT COLOR="#008000">"winmgmts:\.\root\cimv2"</FONT><FONT COLOR="#0000ff">).InvokeMethod1(</FONT><FONT COLOR="#008000">"Get"</FONT><FONT COLOR="#0000ff">,$$$FormatText</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008000">"Win32_Service.Name=%1"</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#0000ff">$$$quote</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">%serviceName</FONT><FONT COLOR="#000000">))</FONT><FONT COLOR="#0000ff">).GetProperty(</FONT><FONT COLOR="#008000">"State"</FONT><FONT COLOR="#0000ff">)

  f </FONT><FONT COLOR="#800000">s</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"wudfsvc"</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#008000">"WSearch" </FONT><FONT COLOR="#0000ff">w </FONT><FONT COLOR="#800000">s</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#008000">": "</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#0000ff">$$$getServState</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">s</FONT><FONT COLOR="#000000">),!</FONT>

Result:
USER><FONT COLOR="#0000ff">d </FONT><FONT COLOR="#000000">^test</FONT>
wudfsvc: Stopped
WSearch: Running

Vitaliy Serdtsev · Jul 16, 2018 go to post

Components Installed by Setup Type: IRIS, Caché

Unfortunately, Perl/Python Binding supported only on the x86-32 bit platform, but IRIS is only supported for x86-64.

Vitaliy Serdtsev · Jul 6, 2018 go to post

Contents of a Script File:

Script files are line oriented; there is no line-continuation convention. Each line is separate from any other. Lines beginning with a semicolon are considered comments. You can use blank lines liberally to improve readability. Normally, invalid lines are ignored. Script commands may be preceded by spaces and/or tabs.

Vitaliy Serdtsev · Jul 6, 2018 go to post

Example of converting a CSV to JSON file and then reading from a JSON file without creating intermediate classes/tables:

  <FONT COLOR="#008000">; CSV -> JSON

  </FONT><FONT COLOR="#0000ff">s </FONT><FONT COLOR="#800000">rowtype </FONT><FONT COLOR="#000000">= </FONT><FONT COLOR="#008000">"name VARCHAR(50),year INTEGER,amount NUMERIC(9,2),date DATE"</FONT><FONT COLOR="#000000">,     </FONT><FONT COLOR="#800000">fileIn </FONT><FONT COLOR="#000000">= </FONT><FONT COLOR="#008000">"C:\Temp\import.csv"</FONT><FONT COLOR="#000000">,     </FONT><FONT COLOR="#800000">fileOut </FONT><FONT COLOR="#000000">= </FONT><FONT COLOR="#008000">"C:\Temp\export.json"</FONT><FONT COLOR="#000000">,     </FONT><FONT COLOR="#800000">fileExp</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#000080">##class</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008080">%Stream.FileBinary</FONT><FONT COLOR="#000000">).</FONT><FONT COLOR="#0000ff">%New</FONT><FONT COLOR="#000000">(),     </FONT><FONT COLOR="#800000">obj</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#000080">##class</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008080">%Document.Object</FONT><FONT COLOR="#000000">).</FONT><FONT COLOR="#0000ff">%New</FONT><FONT COLOR="#000000">()

  </FONT><FONT COLOR="#0000ff">d </FONT><FONT COLOR="#800000">obj</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">loadResultSet</FONT><FONT COLOR="#000000">(</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">"call %SQL_Util.CSV(,?,?)"</FONT><FONT COLOR="#000000">,.</FONT><FONT COLOR="#800000">rowtype</FONT><FONT COLOR="#000000">,.</FONT><FONT COLOR="#800000">fileIn</FONT><FONT COLOR="#000000">),</FONT><FONT COLOR="#008000">"res"</FONT><FONT COLOR="#000000">),     </FONT><FONT COLOR="#800000">fileExp</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">LinkToFile</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">fileOut</FONT><FONT COLOR="#000000">),     </FONT><FONT COLOR="#800000">obj</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">%ToJSONStream</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">fileExp</FONT><FONT COLOR="#000000">),     </FONT><FONT COLOR="#800000">fileExp</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">%Save</FONT><FONT COLOR="#000000">()

  </FONT><FONT COLOR="#008000">; Read JSON

  </FONT><FONT COLOR="#0000ff">s </FONT><FONT COLOR="#800000">fileImp</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#000080">##class</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008080">%Stream.FileBinary</FONT><FONT COLOR="#000000">).</FONT><FONT COLOR="#0000ff">%New</FONT><FONT COLOR="#000000">()   </FONT><FONT COLOR="#0000ff">d </FONT><FONT COLOR="#800000">fileImp</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">LinkToFile</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">fileOut</FONT><FONT COLOR="#000000">)   </FONT><FONT COLOR="#0000ff">s </FONT><FONT COLOR="#800000">obj </FONT><FONT COLOR="#000000">= </FONT><FONT COLOR="#000080">##class</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008080">%DynamicAbstractObject</FONT><FONT COLOR="#000000">).</FONT><FONT COLOR="#0000ff">%FromJSON</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">fileImp</FONT><FONT COLOR="#000000">)   </FONT><FONT COLOR="#0000ff">d </FONT><FONT COLOR="#800000">obj</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">%ToJSON</FONT><FONT COLOR="#000000">()   </FONT><FONT COLOR="#0000ff">w </FONT><FONT COLOR="#000000">!,</FONT><FONT COLOR="#008000">"obj.res.%Size() = "</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#800000">obj</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">res</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">%Size</FONT><FONT COLOR="#000000">()     ,!,</FONT><FONT COLOR="#800000">obj</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">res</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">"0"</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">"""date"""</FONT>

Result:
C:\Temp\import.csv:
car,2000,100.51,27.10.2016,
phone,2003,65.8,15.01.2017,

USER><FONT COLOR="#0000ff">d </FONT><FONT COLOR="#000000">^test</FONT> <FONT COLOR="#ff00ff">{</FONT><FONT COLOR="#008000">"res"</FONT><FONT COLOR="#808080">:</FONT><FONT COLOR="#ff00ff">[{</FONT><FONT COLOR="#008000">"&quot;date&quot;"</FONT><FONT COLOR="#808080">:</FONT><FONT COLOR="#008000">"27.10.2016"</FONT><FONT COLOR="#808080">,</FONT><FONT COLOR="#008000">"amount"</FONT><FONT COLOR="#808080">:</FONT><FONT COLOR="#000000">100.51</FONT><FONT COLOR="#808080">,</FONT><FONT COLOR="#008000">"name"</FONT><FONT COLOR="#808080">:</FONT><FONT COLOR="#008000">"car"</FONT><FONT COLOR="#808080">,</FONT><FONT COLOR="#008000">"year"</FONT><FONT COLOR="#808080">:</FONT><FONT COLOR="#000000">2000</FONT><FONT COLOR="#ff00ff">}</FONT><FONT COLOR="#808080">,</FONT><FONT COLOR="#ff00ff">{</FONT><FONT COLOR="#008000">"&quot;date&quot;"</FONT><FONT COLOR="#808080">:</FONT><FONT COLOR="#008000">"15.01.2017"</FONT><FONT COLOR="#808080">,</FONT><FONT COLOR="#008000">"amount"</FONT><FONT COLOR="#808080">:</FONT><FONT COLOR="#000000">65.8</FONT><FONT COLOR="#808080">,</FONT><FONT COLOR="#008000">"name"</FONT><FONT COLOR="#808080">:</FONT><FONT COLOR="#008000">"phone"</FONT><FONT COLOR="#808080">,</FONT><FONT COLOR="#008000">"year"</FONT><FONT COLOR="#808080">:</FONT><FONT COLOR="#000000">2003</FONT><FONT COLOR="#ff00ff">}]}</FONT> obj.res.%Size() = 2 27.10.2016

Vitaliy Serdtsev · Jun 26, 2018 go to post
TEST1(STATUS=1)
 MSG
 ("(IN,OUT) S OUT=$S(IN:""HELLO"", 1:""GOODBYE"")",STATUS,.MSG)
 
 !,MSG
 Q
 
TEST2(STATUS=1) PUBLIC {
 ("(IN,OUT) S OUT=$S(IN:""HELLO"", 1:""GOODBYE"")",STATUS,.MSG)

 !,MSG
}
Vitaliy Serdtsev · Jun 25, 2018 go to post

Try the following example of uploading multiple files at once, showing the progress for each file you upload (without form, submit, iframe, jQuery, flash, java, reloading/redrawing the page):

<!DOCTYPE html>
  <html>
  <head>
    <title>Upload multiple files using XMLHttpRequest</title>

    <style type="text/css">
    .ok {
      color:green;
    }

    #dropZone {
      width: 360px;
      height: 125px;
      borderdashed 2px #ccc;
      background-color: #fefefe;
      color: #ccc;
      text-aligncenter;
      padding: 125px 0 0 0;
    }
  </style>
    
  </head>
<body onload="onloadHandler()">
<div id="dropZone">Drag and drop files here or use the button below</div>
<div>
  Select files
  <input type="file" id="fileToUpload" onchange="fileSelected(document.getElementById('fileToUpload').files)" multiple="multiple" />
</div>
<button type="button" title="Clearing the queue" onclick="clearList();">Clear</button>
<button type="button" title="Upload files to the server" onclick="upFile();">Upload</button>
<div id="holder"></div>
<script language="javascript">
function clearList()
{
  fileQueue=[];
  document.getElementById('holder').innerHTML='';
  document.getElementById('fileToUpload').value='';
}

function fileSelected(files){
  var holder document.getElementById('holder');
  for (var = 0; i files.length; i++) {
  
    var file files[i];

    var fileSize = 0;
    if (file.size > 1024 * 1024)
      fileSize (Math.round(file.size * 100 / (1024 * 1024)) / 100).toString() 'Mbyte';
    else
      fileSize (Math.round(file.size * 100 / 1024/ 100).toString() 'Kbyte';
  
    var divInfo document.createElement('div');
    divInfo.innerHTML=file.name+' ('+file.type+') - '+fileSize;
    holder.appendChild(divInfo);

    var divProgN document.createElement('div');
    divProgN.id='progressNumber'+i;
    divProgN.innerHTML='%';
    holder.appendChild(divProgN);

    var prog document.createElement('progress');
    prog.id='progressValue'+i;
    prog.max='100.0';
    prog.value='0';
    holder.appendChild(prog);

    fileQueue.push({i:i,file:file});
  }
}

function upFile()
{
  while (fileQueue.length > 0) {
    var item=fileQueue.pop();
    uploadFile(item.file,item.i);
  }
}

function onloadHandler() {
  if (typeof FileReader == "undefined") alert('Sorry, your browser does not support File API, so this demo will not work correctly');
  
  fileQueue new Array();

  uploadFile function (file, i) {
    var xhr new XMLHttpRequest(), upload xhr.upload, fd new FormData();
    
    fd.append('fUpload', file);

    upload.addEventListener('progress',
    function (evt) {
      if (evt.lengthComputable) {
        var percentComplete Math.round(evt.loaded * 100 / evt.total);

        document.getElementById('progressNumber'+i).innerHTML percentComplete.toString() '%';
        document.getElementById('progressValue'+i).value percentComplete;
        
      }
      else {
        document.getElementById('progressNumber'+i).innerHTML 'Cannot calculate';
      }
      
    }, false);
    upload.addEventListener('load'function (ev) {
      var c=document.getElementById('progressNumber'+i);
      c.className='ok';
      c.innerHTML='OK';
    }, false);
    upload.addEventListener('error'function (ev) {alert('An error occurred while trying to upload the file.');}, false);
    upload.addEventListener('abort'function (ev) {alert('The upload was cancelled by the user or the browser reset the connection.');}, false);
    xhr.open('POST',window.location.href);
    xhr.setRequestHeader('Cache-Control''no-cache');
    xhr.setRequestHeader('X-Requested-With''XMLHttpRequest');
    xhr.send(fd);
  }
  
  dropZone=document.getElementById('dropZone');
  dropZone.addEventListener('dragenter',  function(ev){
    ev.stopPropagation();
    ev.preventDefault();
  }, false);
  dropZone.addEventListener('dragleave',  function(ev){
    ev.stopPropagation();
    ev.preventDefault();
    this.style['backgroundColor''#FEFEFE';
    this.style['borderColor''#CCC';
    this.style['color''#CCC';
  }, false);
  dropZone.addEventListener('dragover',  function(ev){
    ev.stopPropagation();
    ev.preventDefault();
    this.style['backgroundColor''#F0FCF0';
    this.style['borderColor''#3DD13F';
    this.style['color''#3DD13F';
  }, false);
  dropZone.addEventListener('drop',  function(ev){
  ev.stopPropagation();
  ev.preventDefault();
  this.style['backgroundColor''#FEFEFE';
  this.style['borderColor''#CCC';
  this.style['color''#CCC';
  fileSelected(ev.dataTransfer.files);
  }, false);
}
</script>
<script language="Cache" method="OnPreHTTP" arguments="" returntype="%Boolean">
  #dim stream As %CSP.BinaryStream=%request.GetMimeData("fUpload")
  i $IsObject(stream{
    
    // make with the resulting file useful work
    
    ;s ^tmp($i(^tmp),"filename")=stream.FileName
    ;s ^tmp($i(^tmp),"filesize")=stream.Size
    
    q $$$NO
  }
  q $$$YES
</script>
</body>
</html>
Vitaliy Serdtsev · Jun 22, 2018 go to post

Use %UTC instead of %TimeStamp

In this case, all conversions will be performed automatically.

Simple example:
Class dc.test Extends %Persistent Final ]
{

</FONT><FONT COLOR="#000080">Property </FONT><FONT COLOR="#000000">CreationTime </FONT><FONT COLOR="#000080">As %TimeStamp </FONT><FONT COLOR="#000000">[ </FONT><FONT COLOR="#000080">InitialExpression </FONT><FONT COLOR="#000000">= {</FONT><FONT COLOR="#0000ff">$ZDateTime</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#0000ff">$ZTimeStamp</FONT><FONT COLOR="#000000">, 3, 1, 2)} ];

</FONT><FONT COLOR="#000080">Property </FONT><FONT COLOR="#000000">utc </FONT><FONT COLOR="#000080">As %UTC </FONT><FONT COLOR="#000000">[ </FONT><FONT COLOR="#000080">InitialExpression </FONT><FONT COLOR="#000000">= {</FONT><FONT COLOR="#000080">##class</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008080">%UTC</FONT><FONT COLOR="#000000">).</FONT><FONT COLOR="#0000ff">NowUTC</FONT><FONT COLOR="#000000">()} ];

</FONT><FONT COLOR="#000080">/// d ##class(dc.test).Test() 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="#000080">default values</FONT><FONT COLOR="#800080">)   </FONT><FONT COLOR="#0000ff">zw </FONT><FONT COLOR="#000000">^dc.testD      </FONT><FONT COLOR="#0000ff">w </FONT><FONT COLOR="#000000">!      </FONT><FONT COLOR="#008000">; %SelectMode = DISPLAY   </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="#000080">##class</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008080">%SQL.Statement</FONT><FONT COLOR="#000000">).</FONT><FONT COLOR="#0000ff">%New</FONT><FONT COLOR="#000000">(2),</FONT><FONT COLOR="#008000">"select * from dc.test"</FONT><FONT COLOR="#000000">).</FONT><FONT COLOR="#0000ff">%Display</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#0000ff">$c</FONT><FONT COLOR="#000000">(9,9)) </FONT><FONT COLOR="#0000ff">w </FONT><FONT COLOR="#000000">!

  </FONT><FONT COLOR="#008000">; %SelectMode = ODBC   </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="#000080">##class</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008080">%SQL.Statement</FONT><FONT COLOR="#000000">).</FONT><FONT COLOR="#0000ff">%New</FONT><FONT COLOR="#000000">(1),</FONT><FONT COLOR="#008000">"select * from dc.test"</FONT><FONT COLOR="#000000">).</FONT><FONT COLOR="#0000ff">%Display</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#0000ff">$c</FONT><FONT COLOR="#000000">(9,9)) </FONT><FONT COLOR="#0000ff">w </FONT><FONT COLOR="#000000">!

  </FONT><FONT COLOR="#008000">; %SelectMode = LOGICAL   </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="#000080">##class</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008080">%SQL.Statement</FONT><FONT COLOR="#000000">).</FONT><FONT COLOR="#0000ff">%New</FONT><FONT COLOR="#000000">(0),</FONT><FONT COLOR="#008000">"select * from dc.test"</FONT><FONT COLOR="#000000">).</FONT><FONT COLOR="#0000ff">%Display</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#0000ff">$c</FONT><FONT COLOR="#000000">(9,9)) } }</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>
^dc.testD=1
^dc.testD(1)=$lb("2018-06-22 14:58:11.61","2018-06-22 14:58:11.618") <FONT COLOR="red">note that the database stores the same values

ID CreationTime utc 1 2018-06-22 14:58:11.61 2018-06-22 17:58:11.618

1 Rows(s) Affected ID CreationTime utc 1 2018-06-22 14:58:11.61 2018-06-22 17:58:11.618

1 Rows(s) Affected ID CreationTime utc 1 2018-06-22 14:58:11.61 2018-06-22 14:58:11.618

1 Rows(s) Affected

Similarly, you can play with the query in the Portal or any ODBC/JDBC client.

PS: don't forget about SQL Functions: %internal()/%external(), %odbcin()/%odbcout().

Vitaliy Serdtsev · Jun 22, 2018 go to post

Useful links:

  1. SQL and NLS Collations
  2. Collations in Caché
This issue dares relatively simply:

  • Create the required collation tables. Fortunately, for some languages, they are already included and can be taken as a basis. In complex cases, you can contact to WRC. Check their list and status:
    USER>zn "%SYS"
    

    %SYS><FONT COLOR="#0000ff">d </FONT><FONT COLOR="#000000">^COLLATE</FONT>

    Status Number Abbrev Name


    Built-in 0 OANS ISM Pre-6.2 Built-in 1 ANSI ISM 6.2->6.4 Built-in 2 COBR Ipsum/Cobra Built-in 3 DTMC DTM-compatible Built-in 4 CBR2 Ipsum/Cobra-2 Built-in 5 UNIC Cache standard Not loaded 10 GER1 German1 Not loaded 11 POR1 Portuguese1 Not loaded 12 POL1 Polish1 Not loaded 13 GER2 German2 Not loaded 14 SPA1 Spanish1 Not loaded 15 DAN1 Danish1 Available 16 CYR1 Cyrillic1 Not loaded 17 GRE1 Greek1 Not loaded 18 CZE1 Czech1 Not loaded 19 CZE2 Czech2 Not loaded 20 POR2 Portuguese2 Not loaded 21 FIN1 Finnish1 Not loaded 22 JAP1 Japanese1 Not loaded 24 POL2 Polish2 Not loaded 27 FRE1 French1 Not loaded 28 FIN2 Finnish2 Available 29 HUN1 Hungarian1 Available 30 GER3 German3 Not loaded 31 POL3 Polish3 Not loaded 32 SPA2 Spanish2 Not loaded 33 DAN2 Danish2 Not loaded 34 GRE2 Greek2 Not loaded 35 FIN3 Finnish3 Not loaded 36 LIT1 Lithuanian1 Available 37 CYR3 Cyrillic3 Not loaded 38 SLO1 Slovenian1 Not loaded 39 SLO2 Slovenian2 Not loaded 40 TUR1 Turkish1 Not loaded 41 DAN3 Danish3 Available 42 UKR1 Ukrainian1 Available 43 CYR4 Cyrillic4 Not loaded 44 CZE3 Czech3 Not loaded 46 MAL1 Maltese1 Not loaded 48 MAL2 Maltese2 Not loaded 49 SPA4 Spanish4 Not loaded 50 SLO1 Slovak1 Not loaded 51 SPA5 Spanish5 Not loaded 52 FIN4 Finnish4 Not loaded 53 CZE4 Czech4 Built-in 128 OSTR ISM Pre-6.2 string Built-in 129 NSTR ISM 6.2->6.4 string Built-in 133 USTR Cache standard string Available 144 CYR1S Cyrillic1 string Available 157 HUN1S Hungarian1 string Available 158 GER3S German3 string Available 165 CYR3S Cyrillic3 string Available 170 UKR1S Ukrainian1 string Available 171 CYR4S Cyrillic4 string

  • load the new collation tables to your current locale
  • for Storage make mapping your indexes in separate globals with own collation
  • Profit!
Here are two small examples:
  1. Class dc.test1 Extends %Persistent
    {
    

    </FONT><FONT COLOR="#000080">Index </FONT><FONT COLOR="#000000">iDE On DescDE </FONT><FONT COLOR="#000080">As </FONT><FONT COLOR="#000000">EXACT;

    </FONT><FONT COLOR="#000080">Index </FONT><FONT COLOR="#000000">iHU On DescHU </FONT><FONT COLOR="#000080">As </FONT><FONT COLOR="#000000">EXACT;

    </FONT><FONT COLOR="#000080">Index </FONT><FONT COLOR="#000000">iRU On DescRU </FONT><FONT COLOR="#000080">As </FONT><FONT COLOR="#000000">EXACT;

    </FONT><FONT COLOR="#000080">Property </FONT><FONT COLOR="#000000">DescDE </FONT><FONT COLOR="#000080">As %String</FONT><FONT COLOR="#000000">;

    </FONT><FONT COLOR="#000080">Property </FONT><FONT COLOR="#000000">DescHU </FONT><FONT COLOR="#000080">As %String</FONT><FONT COLOR="#000000">;

    </FONT><FONT COLOR="#000080">Property </FONT><FONT COLOR="#000000">DescRU </FONT><FONT COLOR="#000080">As %String</FONT><FONT COLOR="#000000">;

    </FONT><FONT COLOR="#000080">ClassMethod </FONT><FONT COLOR="#000000">LoadColTables() [ </FONT><FONT COLOR="#000080">Private </FONT><FONT COLOR="#000000">] {   </FONT><FONT COLOR="#0000ff">s </FONT><FONT COLOR="#800000">r</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#0000ff">$$$NO      try </FONT><FONT COLOR="#800080">{     </FONT><FONT COLOR="#0000ff">$$$AddAllRoleTemporaryInTry     n $namespace        s $namespace</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"%SYS"          </FONT><FONT COLOR="#0000ff">$$$ThrowOnError</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#000080">##class</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008080">Config.NLS.Tables</FONT><FONT COLOR="#000000">).</FONT><FONT COLOR="#0000ff">Load</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008000">"deuw"</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#008000">"COL"</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#008000">"German3"</FONT><FONT COLOR="#000000">))     </FONT><FONT COLOR="#0000ff">$$$ThrowOnError</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#000080">##class</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008080">Config.NLS.Tables</FONT><FONT COLOR="#000000">).</FONT><FONT COLOR="#0000ff">Load</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008000">"hunw"</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#008000">"COL"</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#008000">"Hungarian1"</FONT><FONT COLOR="#000000">))     </FONT><FONT COLOR="#0000ff">$$$ThrowOnError</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#000080">##class</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008080">Config.NLS.Tables</FONT><FONT COLOR="#000000">).</FONT><FONT COLOR="#0000ff">Load</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008000">"rusw"</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#008000">"COL"</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#008000">"Cyrillic4"</FONT><FONT COLOR="#000000">))          </FONT><FONT COLOR="#008000">;d ^COLLATE ; for check only

        </FONT><FONT COLOR="#0000ff">s </FONT><FONT COLOR="#800000">r</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#0000ff">$$$YES   </FONT><FONT COLOR="#800080">}</FONT><FONT COLOR="#0000ff">catch</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">ex</FONT><FONT COLOR="#000000">) </FONT><FONT COLOR="#800080">{     </FONT><FONT COLOR="#0000ff">w </FONT><FONT COLOR="#800000">ex</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">DisplayString</FONT><FONT COLOR="#000000">(),!   </FONT><FONT COLOR="#800080">}

      </FONT><FONT COLOR="#0000ff">q </FONT><FONT COLOR="#800000">r </FONT><FONT COLOR="#000000">}

    </FONT><FONT COLOR="#000080">/// d ##class(dc.test1).Test() ClassMethod </FONT><FONT COLOR="#000000">Test() {   </FONT><FONT COLOR="#0000ff">q</FONT><FONT COLOR="#000000">:'..</FONT><FONT COLOR="#0000ff">LoadColTables</FONT><FONT COLOR="#000000">()      </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">test1</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008000">DescDE</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#008000">DescHU</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#008000">DescRU</FONT><FONT COLOR="#000000">)   </FONT><FONT COLOR="#0000ff">select </FONT><FONT COLOR="#008080">'Straßer'</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#008080">'csak'</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#008080">'Прохор' </FONT><FONT COLOR="#000080">union all   </FONT><FONT COLOR="#0000ff">select </FONT><FONT COLOR="#008080">'Straster'</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#008080">'comb'</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#008080">'Павел' </FONT><FONT COLOR="#000080">union all   </FONT><FONT COLOR="#0000ff">select </FONT><FONT COLOR="#008080">'Strasser'</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#008080">'cukor'</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#008080">'Пётр'</FONT><FONT COLOR="#800080">)      </FONT><FONT COLOR="#0000ff">zw </FONT><FONT COLOR="#000000">^dc.test1D   </FONT><FONT COLOR="#0000ff">w </FONT><FONT COLOR="#000000">!,</FONT><FONT COLOR="#008000">"---- Before (for all indexes by default = 'Cache standard') --------"</FONT><FONT COLOR="#000000">,!!   </FONT><FONT COLOR="#0000ff">d </FONT><FONT COLOR="#ff0000">print      </FONT><FONT COLOR="#0000ff">w </FONT><FONT COLOR="#000000">!,</FONT><FONT COLOR="#008000">"---- After (each index has its own collation) --------"</FONT><FONT COLOR="#000000">,!!   </FONT><FONT COLOR="#0000ff">d </FONT><FONT COLOR="#000000">..</FONT><FONT COLOR="#0000ff">%PurgeIndices</FONT><FONT COLOR="#000000">()      </FONT><FONT COLOR="#0000ff">d $system</FONT><FONT COLOR="#008080">.OBJ</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">DisplayError</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#000080">##class</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008080">%GlobalEdit</FONT><FONT COLOR="#000000">).</FONT><FONT COLOR="#0000ff">Create</FONT><FONT COLOR="#000000">(,</FONT><FONT COLOR="#008000">"dc.test1.iDE"</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#000080">##class</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008080">%Collate</FONT><FONT COLOR="#000000">).</FONT><FONT COLOR="#0000ff">DisplayToLogical</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008000">"German3"</FONT><FONT COLOR="#000000">)))    ,</FONT><FONT COLOR="#0000ff">$system</FONT><FONT COLOR="#008080">.OBJ</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">DisplayError</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#000080">##class</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008080">%GlobalEdit</FONT><FONT COLOR="#000000">).</FONT><FONT COLOR="#0000ff">Create</FONT><FONT COLOR="#000000">(,</FONT><FONT COLOR="#008000">"dc.test1.iHU"</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#000080">##class</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008080">%Collate</FONT><FONT COLOR="#000000">).</FONT><FONT COLOR="#0000ff">DisplayToLogical</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008000">"Hungarian1"</FONT><FONT COLOR="#000000">)))    ,</FONT><FONT COLOR="#0000ff">$system</FONT><FONT COLOR="#008080">.OBJ</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">DisplayError</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#000080">##class</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008080">%GlobalEdit</FONT><FONT COLOR="#000000">).</FONT><FONT COLOR="#0000ff">Create</FONT><FONT COLOR="#000000">(,</FONT><FONT COLOR="#008000">"dc.test1.iRU"</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#000080">##class</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008080">%Collate</FONT><FONT COLOR="#000000">).</FONT><FONT COLOR="#0000ff">DisplayToLogical</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008000">"Cyrillic4"</FONT><FONT COLOR="#000000">)))    ,..</FONT><FONT COLOR="#0000ff">%BuildIndices</FONT><FONT COLOR="#000000">(,</FONT><FONT COLOR="#0000ff">$$$NO</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#0000ff">$$$YES</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#0000ff">$$$NO</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><FONT COLOR="#ff0000">print

      </FONT><FONT COLOR="#0000ff">q

    </FONT><FONT COLOR="#ff0000">print     </FONT><FONT COLOR="#0000ff">zw </FONT><FONT COLOR="#000000">^dc.test1.iDE,^dc.test1.iHU,^dc.test1.iRU   </FONT><FONT COLOR="#0000ff">w </FONT><FONT COLOR="#000000">!   </FONT><FONT COLOR="#0000ff">f </FONT><FONT COLOR="#800000">lng</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"DE"</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#008000">"HU"</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#008000">"RU" </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="#0000ff">$$$FormatText</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008000">"select %ID,Desc%1 from dc.test1 order by %exact(Desc%1)"</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#800000">lng</FONT><FONT COLOR="#000000">)).</FONT><FONT COLOR="#0000ff">%Display</FONT><FONT COLOR="#000000">() </FONT><FONT COLOR="#0000ff">w </FONT><FONT COLOR="#000000">!!   </FONT><FONT COLOR="#0000ff">q </FONT><FONT COLOR="#000000">}

    </FONT><FONT COLOR="#000080">Storage </FONT><FONT COLOR="#000000">Default { <Data name="</FONT><FONT COLOR="#000080">test1DefaultData</FONT><FONT COLOR="#000000">"> <Value name="</FONT><FONT COLOR="#000080">1</FONT><FONT COLOR="#000000">"> <Value>%%CLASSNAME</Value> </Value> <Value name="</FONT><FONT COLOR="#000080">2</FONT><FONT COLOR="#000000">"> <Value>DescDE</Value> </Value> <Value name="</FONT><FONT COLOR="#000080">3</FONT><FONT COLOR="#000000">"> <Value>DescHU</Value> </Value> <Value name="</FONT><FONT COLOR="#000080">4</FONT><FONT COLOR="#000000">"> <Value>DescRU</Value> </Value> </Data> <DataLocation>^dc.test1D</DataLocation> <DefaultData>test1DefaultData</DefaultData> <IdLocation>^dc.test1D</IdLocation> <Index name="</FONT><FONT COLOR="#000080">iDE</FONT><FONT COLOR="#000000">"> <Location>^dc.test1.iDE</Location> </Index> <Index name="</FONT><FONT COLOR="#000080">iHU</FONT><FONT COLOR="#000000">"> <Location>^dc.test1.iHU</Location> </Index> <Index name="</FONT><FONT COLOR="#000080">iRU</FONT><FONT COLOR="#000000">"> <Location>^dc.test1.iRU</Location> </Index> <IndexLocation>^dc.test1I</IndexLocation> <StreamLocation>^dc.test1S</StreamLocation> <Type>%Library.CacheStorage</Type> }

    }</FONT>

    Result:
    USER><FONT COLOR="#0000ff">d </FONT><FONT COLOR="#000080">##class</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008080">dc.test1</FONT><FONT COLOR="#000000">).</FONT><FONT COLOR="#0000ff">Test</FONT><FONT COLOR="#000000">()</FONT>
    ^dc.test1D=3
    ^dc.test1D(1)=$lb("","Straßer","csak","Прохор")
    ^dc.test1D(2)=$lb("","Straster","comb","Павел")
    ^dc.test1D(3)=$lb("","Strasser","cukor","Пётр")

    <FONT style="Background-COLOR:red;color:yellow">---- Before (for all indexes by default = 'Cache standard') --------</FONT>

    ^dc.test1.iDE("Strasser",3)="" ^dc.test1.iDE("Straster",2)="" ^dc.test1.iDE("Straßer",1)="" ^dc.test1.iHU("comb",2)="" ^dc.test1.iHU("csak",1)="" ^dc.test1.iHU("cukor",3)="" ^dc.test1.iRU("Павел",2)="" ^dc.test1.iRU("Прохор",1)="" ^dc.test1.iRU("Пётр",3)=""

    ID DescDE 3 Strasser 2 Straster 1 Straßer

    3 Rows(s) Affected

    ID DescHU 2 comb 1 csak 3 cukor

    3 Rows(s) Affected

    ID DescRU 2 Павел 1 Прохор 3 Пётр

    3 Rows(s) Affected

    <FONT style="background-color:green;color:yellow">---- After (each index has its own collation) --------</FONT>

    ^dc.test1.iDE("Strasser",3)="" ^dc.test1.iDE("Straßer",1)="" ^dc.test1.iDE("Straster",2)="" ^dc.test1.iHU("comb",2)="" ^dc.test1.iHU("cukor",3)="" ^dc.test1.iHU("csak",1)="" ^dc.test1.iRU("Павел",2)="" ^dc.test1.iRU("Пётр",3)="" ^dc.test1.iRU("Прохор",1)=""

    ID DescDE 3 Strasser 1 Straßer 2 Straster

    3 Rows(s) Affected

    ID DescHU 2 comb 3 cukor 1 csak

    3 Rows(s) Affected

    ID DescRU 2 Павел 3 Пётр 1 Прохор

    3 Rows(s) Affected

  2. Class dc.test2 Extends %Persistent
    {
    

    </FONT><FONT COLOR="#000080">Index </FONT><FONT COLOR="#000000">iDE On (Lng, Descr </FONT><FONT COLOR="#000080">As </FONT><FONT COLOR="#000000">EXACT);

    </FONT><FONT COLOR="#000080">Index </FONT><FONT COLOR="#000000">iHU On (Lng, Descr </FONT><FONT COLOR="#000080">As </FONT><FONT COLOR="#000000">EXACT);

    </FONT><FONT COLOR="#000080">Index </FONT><FONT COLOR="#000000">iRU On (Lng, Descr </FONT><FONT COLOR="#000080">As </FONT><FONT COLOR="#000000">EXACT);

    </FONT><FONT COLOR="#000080">Property </FONT><FONT COLOR="#000000">Lng </FONT><FONT COLOR="#000080">As %String</FONT><FONT COLOR="#000000">;

    </FONT><FONT COLOR="#000080">Property </FONT><FONT COLOR="#000000">Descr </FONT><FONT COLOR="#000080">As %String</FONT><FONT COLOR="#000000">;

    </FONT><FONT COLOR="#000080">/// d ##class(dc.test2).Test() 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="#0000ff">$system</FONT><FONT COLOR="#008080">.OBJ</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">DisplayError</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#000080">##class</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008080">%GlobalEdit</FONT><FONT COLOR="#000000">).</FONT><FONT COLOR="#0000ff">Create</FONT><FONT COLOR="#000000">(,</FONT><FONT COLOR="#008000">"dc.test2.iDE"</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#000080">##class</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008080">%Collate</FONT><FONT COLOR="#000000">).</FONT><FONT COLOR="#0000ff">DisplayToLogical</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008000">"German3"</FONT><FONT COLOR="#000000">)))    ,</FONT><FONT COLOR="#0000ff">$system</FONT><FONT COLOR="#008080">.OBJ</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">DisplayError</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#000080">##class</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008080">%GlobalEdit</FONT><FONT COLOR="#000000">).</FONT><FONT COLOR="#0000ff">Create</FONT><FONT COLOR="#000000">(,</FONT><FONT COLOR="#008000">"dc.test2.iHU"</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#000080">##class</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008080">%Collate</FONT><FONT COLOR="#000000">).</FONT><FONT COLOR="#0000ff">DisplayToLogical</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008000">"Hungarian1"</FONT><FONT COLOR="#000000">)))    ,</FONT><FONT COLOR="#0000ff">$system</FONT><FONT COLOR="#008080">.OBJ</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">DisplayError</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#000080">##class</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008080">%GlobalEdit</FONT><FONT COLOR="#000000">).</FONT><FONT COLOR="#0000ff">Create</FONT><FONT COLOR="#000000">(,</FONT><FONT COLOR="#008000">"dc.test2.iRU"</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#000080">##class</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008080">%Collate</FONT><FONT COLOR="#000000">).</FONT><FONT COLOR="#0000ff">DisplayToLogical</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008000">"Cyrillic4"</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">test2</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008000">Lng</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#008000">Descr</FONT><FONT COLOR="#000000">)   </FONT><FONT COLOR="#0000ff">select </FONT><FONT COLOR="#008080">'DE'</FONT><FONT COLOR="#000000">, </FONT><FONT COLOR="#008080">'Straßer' </FONT><FONT COLOR="#000080">union   </FONT><FONT COLOR="#0000ff">select </FONT><FONT COLOR="#008080">'DE'</FONT><FONT COLOR="#000000">, </FONT><FONT COLOR="#008080">'Straster' </FONT><FONT COLOR="#000080">union   </FONT><FONT COLOR="#0000ff">select </FONT><FONT COLOR="#008080">'DE'</FONT><FONT COLOR="#000000">, </FONT><FONT COLOR="#008080">'Strasser' </FONT><FONT COLOR="#000080">union   </FONT><FONT COLOR="#0000ff">select </FONT><FONT COLOR="#008080">'HU'</FONT><FONT COLOR="#000000">, </FONT><FONT COLOR="#008080">'csak' </FONT><FONT COLOR="#000080">union   </FONT><FONT COLOR="#0000ff">select </FONT><FONT COLOR="#008080">'HU'</FONT><FONT COLOR="#000000">, </FONT><FONT COLOR="#008080">'comb' </FONT><FONT COLOR="#000080">union   </FONT><FONT COLOR="#0000ff">select </FONT><FONT COLOR="#008080">'HU'</FONT><FONT COLOR="#000000">, </FONT><FONT COLOR="#008080">'cukor' </FONT><FONT COLOR="#000080">union   </FONT><FONT COLOR="#0000ff">select </FONT><FONT COLOR="#008080">'RU'</FONT><FONT COLOR="#000000">, </FONT><FONT COLOR="#008080">'Прохор' </FONT><FONT COLOR="#000080">union   </FONT><FONT COLOR="#0000ff">select </FONT><FONT COLOR="#008080">'RU'</FONT><FONT COLOR="#000000">, </FONT><FONT COLOR="#008080">'Павел' </FONT><FONT COLOR="#000080">union   </FONT><FONT COLOR="#0000ff">select </FONT><FONT COLOR="#008080">'RU'</FONT><FONT COLOR="#000000">, </FONT><FONT COLOR="#008080">'Пётр'</FONT><FONT COLOR="#800080">)      </FONT><FONT COLOR="#0000ff">zw </FONT><FONT COLOR="#000000">^dc.test2D,^dc.test2.iDE,^dc.test2.iHU,^dc.test2.iRU      </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="#ff0000">print

      </FONT><FONT COLOR="#0000ff">q

    </FONT><FONT COLOR="#ff0000">print     </FONT><FONT COLOR="#0000ff">w </FONT><FONT COLOR="#000000">!   </FONT><FONT COLOR="#0000ff">f </FONT><FONT COLOR="#800000">lng</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"DE"</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#008000">"HU"</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#008000">"RU" </FONT><FONT COLOR="#800080">{     </FONT><FONT COLOR="#0000ff">s </FONT><FONT COLOR="#800000">idx</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#0000ff">$replace</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008000">"iDE,iHU,iRU"</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#008000">"i"</FONT><FONT COLOR="#000000">_</FONT><FONT COLOR="#800000">lng</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#008000">"i"</FONT><FONT COLOR="#000000"></FONT><FONT COLOR="#800000">lng</FONT><FONT COLOR="#000000">)     </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="#0000ff">$$$FormatText</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008000">"select * from %IGNOREINDEX %1 dc.test2 where Lng=? order by %exact(Descr)"</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#800000">idx</FONT><FONT COLOR="#000000">),</FONT><FONT COLOR="#800000">lng</FONT><FONT COLOR="#000000">).</FONT><FONT COLOR="#0000ff">%Display</FONT><FONT COLOR="#000000">()     </FONT><FONT COLOR="#0000ff">w </FONT><FONT COLOR="#000000">!!   </FONT><FONT COLOR="#800080">}   </FONT><FONT COLOR="#0000ff">q </FONT><FONT COLOR="#000000">}

    </FONT><FONT COLOR="#000080">Storage </FONT><FONT COLOR="#000000">Default { <Data name="</FONT><FONT COLOR="#000080">test2DefaultData</FONT><FONT COLOR="#000000">"> <Value name="</FONT><FONT COLOR="#000080">1</FONT><FONT COLOR="#000000">"> <Value>%%CLASSNAME</Value> </Value> <Value name="</FONT><FONT COLOR="#000080">2</FONT><FONT COLOR="#000000">"> <Value>Lng</Value> </Value> <Value name="</FONT><FONT COLOR="#000080">3</FONT><FONT COLOR="#000000">"> <Value>Descr</Value> </Value> </Data> <DataLocation>^dc.test2D</DataLocation> <DefaultData>test2DefaultData</DefaultData> <IdLocation>^dc.test2D</IdLocation> <Index name="</FONT><FONT COLOR="#000080">iDE</FONT><FONT COLOR="#000000">"> <Location>^dc.test2.iDE</Location> </Index> <Index name="</FONT><FONT COLOR="#000080">iHU</FONT><FONT COLOR="#000000">"> <Location>^dc.test2.iHU</Location> </Index> <Index name="</FONT><FONT COLOR="#000080">iRU</FONT><FONT COLOR="#000000">"> <Location>^dc.test2.iRU</Location> </Index> <IndexLocation>^dc.test2I</IndexLocation> <StreamLocation>^dc.test2S</StreamLocation> <Type>%Library.CacheStorage</Type> }

    }</FONT>

    Result:
    USER><FONT COLOR="#0000ff">d </FONT><FONT COLOR="#000080">##class</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008080">dc.test2</FONT><FONT COLOR="#000000">).</FONT><FONT COLOR="#0000ff">Test</FONT><FONT COLOR="#000000">()</FONT>
    ^dc.test2D=9
    ^dc.test2D(1)=$lb("","DE","Straßer")
    ^dc.test2D(2)=$lb("","DE","Straster")
    ^dc.test2D(3)=$lb("","DE","Strasser")
    ^dc.test2D(4)=$lb("","HU","csak")
    ^dc.test2D(5)=$lb("","HU","comb")
    ^dc.test2D(6)=$lb("","HU","cukor")
    ^dc.test2D(7)=$lb("","RU","Прохор")
    ^dc.test2D(8)=$lb("","RU","Павел")
    ^dc.test2D(9)=$lb("","RU","Пётр")
    ^dc.test2.iDE(" DE","Strasser",3)=""
    ^dc.test2.iDE(" DE","Straßer",1)=""
    ^dc.test2.iDE(" DE","Straster",2)=""
    ^dc.test2.iDE(" HU","comb",5)=""
    ^dc.test2.iDE(" HU","csak",4)=""
    ^dc.test2.iDE(" HU","cukor",6)=""
    ^dc.test2.iDE(" RU","Павел",8)=""
    ^dc.test2.iDE(" RU","Прохор",7)=""
    ^dc.test2.iDE(" RU","Пётр",9)=""
    ^dc.test2.iHU(" DE","Strasser",3)=""
    ^dc.test2.iHU(" DE","Straster",2)=""
    ^dc.test2.iHU(" DE","Straßer",1)=""
    ^dc.test2.iHU(" HU","comb",5)=""
    ^dc.test2.iHU(" HU","cukor",6)=""
    ^dc.test2.iHU(" HU","csak",4)=""
    ^dc.test2.iHU(" RU","Павел",8)=""
    ^dc.test2.iHU(" RU","Прохор",7)=""
    ^dc.test2.iHU(" RU","Пётр",9)=""
    ^dc.test2.iRU(" DE","Strasser",3)=""
    ^dc.test2.iRU(" DE","Straster",2)=""
    ^dc.test2.iRU(" DE","Straßer",1)=""
    ^dc.test2.iRU(" HU","comb",5)=""
    ^dc.test2.iRU(" HU","csak",4)=""
    ^dc.test2.iRU(" HU","cukor",6)=""
    ^dc.test2.iRU(" RU","Павел",8)=""
    ^dc.test2.iRU(" RU","Пётр",9)=""
    ^dc.test2.iRU(" RU","Прохор",7)=""

    ID Descr Lng 3 Strasser DE 1 Straßer DE 2 Straster DE

    3 Rows(s) Affected

    ID Descr Lng 5 comb HU 6 cukor HU 4 csak HU

    3 Rows(s) Affected

    ID Descr Lng 8 Павел RU 9 Пётр RU 7 Прохор RU

    3 Rows(s) Affected

Important: if you remove "As EXACT" in the index, the examples will not work correctly for the German language, because: Capital ẞ

Vitaliy Serdtsev · Jun 15, 2018 go to post

Add the RenderDirectlyOnTimeout property in the report:

Property RenderDirectlyOnTimeout As %ZEN.Datatype.boolean(ZENURL "$RENDERDIRECTLYONTIMEOUT") [ InitialExpression = {$$$NO} ];

Then you will get the following error:

ERROR #5001: Cannot contact server on port %1.
or
ERROR #5001: Received Control-C or there was a fatal error.

Vitaliy Serdtsev · Jun 14, 2018 go to post

Try so:

<FONT COLOR="#000080">Class dc.test Extends %ZEN.Component.page
</FONT><FONT COLOR="#000000">{

</FONT><FONT COLOR="#000080">XData </FONT><FONT COLOR="#000000">Contents [ </FONT><FONT COLOR="#000080">XMLNamespace </FONT><FONT COLOR="#000000">= </FONT><FONT COLOR="#800080">"http://www.intersystems.com/zen" </FONT><FONT COLOR="#000000">] {   <</FONT><FONT COLOR="#000080">page </FONT><FONT COLOR="#800000">xmlns</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"http://www.intersystems.com/zen"</FONT><FONT COLOR="#000000">>     <</FONT><FONT COLOR="#000080">button </FONT><FONT COLOR="#800000">id</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"btn1" </FONT><FONT COLOR="#800000">caption</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"Test Server"</FONT><FONT COLOR="#000000">/>     <</FONT><FONT COLOR="#000080">button </FONT><FONT COLOR="#800000">id</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"btn2" </FONT><FONT COLOR="#800000">caption</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"Test Client"</FONT><FONT COLOR="#000000">/>   </</FONT><FONT COLOR="#000080">page</FONT><FONT COLOR="#000000">> }

</FONT><FONT COLOR="#000080">ClassMethod </FONT><FONT COLOR="#000000">SrvTest() [ </FONT><FONT COLOR="#000080">ZenMethod </FONT><FONT COLOR="#000000">] {   </FONT><FONT COLOR="#800080">&js<</FONT><FONT COLOR="#000000">zenAlert(</FONT><FONT COLOR="#800000">'from Server'</FONT><FONT COLOR="#000000">);</FONT><FONT COLOR="#800080">> </FONT><FONT COLOR="#000000">}

</FONT><FONT COLOR="#000080">ClientMethod </FONT><FONT COLOR="#000000">test() [ </FONT><FONT COLOR="#000080">Language </FONT><FONT COLOR="#000000">= javascript ] {   zenAlert(</FONT><FONT COLOR="#800000">'from Client'</FONT><FONT COLOR="#000000">); }

</FONT><FONT COLOR="#000080">ClientMethod </FONT><FONT COLOR="#000000">onloadHandler() [ </FONT><FONT COLOR="#000080">Language </FONT><FONT COLOR="#000000">= javascript ] {   document.getElementById(</FONT><FONT COLOR="#800000">'btn1'</FONT><FONT COLOR="#000000">).addEventListener(</FONT><FONT COLOR="#800000">'click'</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#800000">new </FONT><FONT COLOR="#000000">Function(</FONT><FONT COLOR="#800000">'evt'</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#800000">'return zenPage.SrvTest();'</FONT><FONT COLOR="#000000">),false);   document.getElementById(</FONT><FONT COLOR="#800000">'btn2'</FONT><FONT COLOR="#000000">).addEventListener(</FONT><FONT COLOR="#800000">'click'</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#800000">new </FONT><FONT COLOR="#000000">Function(</FONT><FONT COLOR="#800000">'evt'</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#800000">'return zenPage.test();'</FONT><FONT COLOR="#000000">),false); } }</FONT>

Vitaliy Serdtsev · Jun 14, 2018 go to post

Suppose there is such a code:

int caseSwitch = 1;
 
switch (caseSwitch)
{
case 1:
Console.WriteLine("Case 1");
//a lot of code
break;
 
case 2:
case 8-9:
Console.WriteLine("Case 2 or 8 or 9");
//a lot of code
break;
 
case 3:
Console.WriteLine("Case 3");
//a lot of code
break;
 
/...
a lot conditions
.../
 
default:
Console.WriteLine("Default case");
//a lot of code
break;
}
In this case
  1. $select;if/elseif/else is not effective because for last conditions will have to iterate through all the previous ones
  2. $case is redundant: you will have to specify the same code multiple times for different values

For this particular case, I suggest using a transition table, for example:

<FONT COLOR="#000080">ClassMethod </FONT><FONT COLOR="#000000">Test(</FONT><FONT COLOR="#ff00ff">caseSwitch </FONT><FONT COLOR="#000000">= </FONT><FONT COLOR="#000080">3</FONT><FONT COLOR="#000000">) [ </FONT><FONT COLOR="#000080">ProcedureBlock </FONT><FONT COLOR="#000000">= 0 ]
{
  </FONT><FONT COLOR="#0000ff">s</FONT><FONT COLOR="#000000">:'</FONT><FONT COLOR="#0000ff">$d</FONT><FONT COLOR="#000000">(^||addr) ^||addr(1)=1,
                (^(2),^(8),^(9))=289,
                 ^(3)=3
  
  </FONT><FONT COLOR="#0000ff">d </FONT><FONT COLOR="#000000">@(</FONT><FONT COLOR="#008000">"case"</FONT><FONT COLOR="#000000">_</FONT><FONT COLOR="#0000ff">$g</FONT><FONT COLOR="#000000">(^||addr(</FONT><FONT COLOR="#800000">caseSwitch</FONT><FONT COLOR="#000000">),</FONT><FONT COLOR="#008000">"def"</FONT><FONT COLOR="#000000">))
  </FONT><FONT COLOR="#0000ff">q  

</FONT><FONT COLOR="#ff0000">case1   </FONT><FONT COLOR="#0000ff">w </FONT><FONT COLOR="#008000">"Case 1"   </FONT><FONT COLOR="#0000ff">q </FONT><FONT COLOR="#ff0000">case289   </FONT><FONT COLOR="#0000ff">w </FONT><FONT COLOR="#008000">"Case 2 or 8 or 9"   </FONT><FONT COLOR="#0000ff">q </FONT><FONT COLOR="#ff0000">case3   </FONT><FONT COLOR="#0000ff">w </FONT><FONT COLOR="#008000">"Case 3"   </FONT><FONT COLOR="#0000ff">q </FONT><FONT COLOR="#ff0000">casedef   </FONT><FONT COLOR="#0000ff">w </FONT><FONT COLOR="#008000">"Default case"   </FONT><FONT COLOR="#0000ff">q </FONT><FONT COLOR="#000000">}</FONT>

Of course, you can modify the example to call procedures, functions, class methods, etc.

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 · Jun 13, 2018 go to post

For serial class, I'm afraid that's not possible because of its nature. $this, $classname, etc. in the context of EmbedObj don't know anything about ContainerObj.

Use bidirectional Relationship.

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 12, 2018 go to post

Page numbering in Roman Numerals

Need add the attribute format to the element <fo:page-sequence>, i.e.
<fo:page-sequence master-reference='blablabla' format ='I' .. >

Possible value format:

  • format="1" results in 1 2 3 . .
  • format="01" results in 01 02 03
  • format="a" results in a b c . .
  • format="A" results in A B C. .
  • format="i" results in i ii iii iv . .
  • format="I" results in I II III IV . .
  • more..

Example:

  1. Do all the steps according to Zen Report Tutorial
  2. Insert the page number into <pagefooter>
    <!-- Optional Pagefooter element. Does not apply in HTML output. -->
    <pagefooter>
    <item special="page-number"/>
    </pagefooter>
  3. Insert the following code into the class:
    ClassMethod ReplaceStream(
      ByRef stream As %Stream.TmpBinary,
      format) [ Private ]
    {
      tmp=##class(%Stream.TmpBinary).%New()
      while 'stream.AtEnd {
        tmp.Write($replace(stream.Read($$$MaxLocalLength),"<fo:page-sequence ",$$$FormatText("<fo:page-sequence format=%1 ",$$$quote(format))))
      }
      stream.CopyFrom(tmp)
    }
    

    <FONT COLOR="#000080">/// d ##class(MyApp.ReportDemo).Test() ClassMethod </FONT><FONT COLOR="#000000">Test(</FONT><FONT COLOR="#ff00ff">format </FONT><FONT COLOR="#000000">= </FONT><FONT COLOR="#800080">"1"</FONT><FONT COLOR="#000000">) {   </FONT><FONT COLOR="#008000">/*     •0 = XML     •1 = HTML     •2 = PDF     •3 = ToHTML Stylesheet     •4 = ToXSLFO Stylesheet     •5 = XSD Schema     •6 = PrintPS     •7 = Excel     •8 = XSLFO     •9 = ToEXCEL     •10=xlsx     •11=TIFF     •12=pdfprint     •13=displayxlsx     •14=fo2pdf     •15=foandpdf   */      </FONT><FONT COLOR="#0000ff">s </FONT><FONT COLOR="#800000">xslfo</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#000080">##class</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008080">%Stream.TmpBinary</FONT><FONT COLOR="#000000">).</FONT><FONT COLOR="#0000ff">%New</FONT><FONT COLOR="#000000">()

      </FONT><FONT COLOR="#0000ff">s </FONT><FONT COLOR="#800000">t</FONT><FONT COLOR="#000000">=..</FONT><FONT COLOR="#0000ff">%New</FONT><FONT COLOR="#000000">()   </FONT><FONT COLOR="#0000ff">d </FONT><FONT COLOR="#800000">t</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">GenerateReportToStream</FONT><FONT COLOR="#000000">(.</FONT><FONT COLOR="#800000">xslfo</FONT><FONT COLOR="#000000">,4)   </FONT><FONT COLOR="#0000ff">d </FONT><FONT COLOR="#000000">..</FONT><FONT COLOR="#0000ff">ReplaceStream</FONT><FONT COLOR="#000000">(.</FONT><FONT COLOR="#800000">xslfo</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#800000">format</FONT><FONT COLOR="#000000">)   </FONT><FONT COLOR="#0000ff">s </FONT><FONT COLOR="#800000">t</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">toxslfostream</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#800000">xslfo   </FONT><FONT COLOR="#0000ff">d $system</FONT><FONT COLOR="#008080">.OBJ</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">DisplayError</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">t</FONT><FONT COLOR="#000000">.</FONT><FONT COLOR="#0000ff">GenerateReport</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008000">"c:\temp\test.pdf"</FONT><FONT COLOR="#000000">,2)) }</FONT>

  4. SAMPLES>##class(MyApp.ReportDemo).Test("I")
    or
    SAMPLES>##class(MyApp.ReportDemo).Test("01")
    or
    SAMPLES>##class(MyApp.ReportDemo).Test("A")
  5. open test.pdf. Profit!
Vitaliy Serdtsev · Jun 6, 2018 go to post

Choose to your taste:

<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">Public() [ </FONT><FONT COLOR="#000080">Internal</FONT><FONT COLOR="#000000">, </FONT><FONT COLOR="#000080">Private</FONT><FONT COLOR="#000000">, </FONT><FONT COLOR="#000080">ProcedureBlock </FONT><FONT COLOR="#000000">= 0 ] {   </FONT><FONT COLOR="#0000ff">q </FONT><FONT COLOR="#ff0000">Choice0</FONT><FONT COLOR="#000000">()   </FONT><FONT COLOR="#0000ff">q </FONT><FONT COLOR="#008000">"Sunday" </FONT><FONT COLOR="#ff0000">Choice1</FONT><FONT COLOR="#000000">()   </FONT><FONT COLOR="#0000ff">q </FONT><FONT COLOR="#008000">"Monday" </FONT><FONT COLOR="#ff0000">Choice2</FONT><FONT COLOR="#000000">()   </FONT><FONT COLOR="#0000ff">q </FONT><FONT COLOR="#008000">"Tuesday" </FONT><FONT COLOR="#ff0000">Choice3</FONT><FONT COLOR="#000000">()   </FONT><FONT COLOR="#0000ff">q </FONT><FONT COLOR="#008000">"Wednesday" </FONT><FONT COLOR="#ff0000">Choice4</FONT><FONT COLOR="#000000">()   </FONT><FONT COLOR="#0000ff">q </FONT><FONT COLOR="#008000">"Thursday" </FONT><FONT COLOR="#ff0000">Choice5</FONT><FONT COLOR="#000000">()   </FONT><FONT COLOR="#0000ff">q </FONT><FONT COLOR="#008000">"Friday" </FONT><FONT COLOR="#ff0000">Choice6</FONT><FONT COLOR="#000000">()   </FONT><FONT COLOR="#0000ff">q </FONT><FONT COLOR="#008000">"Saturday" </FONT><FONT COLOR="#ff0000">Choice</FONT><FONT COLOR="#000000">()   </FONT><FONT COLOR="#0000ff">set </FONT><FONT COLOR="#800000">a</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"entry " </FONT><FONT COLOR="#000000">_</FONT><FONT COLOR="#008000">"error"   </FONT><FONT COLOR="#0000ff">return </FONT><FONT COLOR="#800000">a </FONT><FONT COLOR="#000000">}

</FONT><FONT COLOR="#000080">/// d ##class(dc.test).Test() ClassMethod </FONT><FONT COLOR="#000000">Test() {   </FONT><FONT COLOR="#0000ff">s </FONT><FONT COLOR="#800000">daynum</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#0000ff">$zd</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#0000ff">$h</FONT><FONT COLOR="#000000">,10)

  </FONT><FONT COLOR="#0000ff">w </FONT><FONT COLOR="#008000">"1) "</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#0000ff">$case</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">daynum</FONT><FONT COLOR="#000000">,                 0:</FONT><FONT COLOR="#0000ff">$$</FONT><FONT COLOR="#ff0000">Choice0</FONT><FONT COLOR="#000000">,                 1:</FONT><FONT COLOR="#0000ff">$$</FONT><FONT COLOR="#ff0000">Choice1</FONT><FONT COLOR="#000000">,                 2:</FONT><FONT COLOR="#0000ff">$$</FONT><FONT COLOR="#ff0000">Choice2</FONT><FONT COLOR="#000000">,                 3:</FONT><FONT COLOR="#0000ff">$$</FONT><FONT COLOR="#ff0000">Choice3</FONT><FONT COLOR="#000000">,                 4:</FONT><FONT COLOR="#0000ff">$$</FONT><FONT COLOR="#ff0000">Choice4</FONT><FONT COLOR="#000000">,                 5:</FONT><FONT COLOR="#0000ff">$$</FONT><FONT COLOR="#ff0000">Choice5</FONT><FONT COLOR="#000000">,                 6:</FONT><FONT COLOR="#0000ff">$$</FONT><FONT COLOR="#ff0000">Choice6</FONT><FONT COLOR="#000000">,                 :</FONT><FONT COLOR="#0000ff">$$</FONT><FONT COLOR="#ff0000">Choice</FONT><FONT COLOR="#000000">),!

  </FONT><FONT COLOR="#0000ff">w </FONT><FONT COLOR="#008000">"2) "</FONT><FONT COLOR="#000000">,@(</FONT><FONT COLOR="#008000">"$$Choice"</FONT><FONT COLOR="#000000">_</FONT><FONT COLOR="#0000ff">$case</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">daynum</FONT><FONT COLOR="#000000">,                               0:0,                               1:1,                               2:2,                               3:3,                               4:4,                               5:5,                               6:6,                               :</FONT><FONT COLOR="#008000">""</FONT><FONT COLOR="#000000">)),!

  </FONT><FONT COLOR="#0000ff">s </FONT><FONT COLOR="#800000">daynum</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"-"      </FONT><FONT COLOR="#0000ff">w </FONT><FONT COLOR="#008000">"3) "</FONT><FONT COLOR="#000000">,</FONT><FONT COLOR="#0000ff">$case</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#800000">daynum</FONT><FONT COLOR="#000000">,                 0:</FONT><FONT COLOR="#008000">"Sunday"</FONT><FONT COLOR="#000000">,                 1:</FONT><FONT COLOR="#008000">"Monday"</FONT><FONT COLOR="#000000">,                 2:</FONT><FONT COLOR="#008000">"Tuesday"</FONT><FONT COLOR="#000000">,                 3:</FONT><FONT COLOR="#008000">"Wednesday"</FONT><FONT COLOR="#000000">,                 4:</FONT><FONT COLOR="#008000">"Thursday"</FONT><FONT COLOR="#000000">,                 5:</FONT><FONT COLOR="#008000">"Friday"</FONT><FONT COLOR="#000000">,                 6:</FONT><FONT COLOR="#008000">"Saturday"</FONT><FONT COLOR="#000000">,                 :</FONT><FONT COLOR="#0000ff">$xecute</FONT><FONT COLOR="#000000">(</FONT><FONT COLOR="#008000">"()"</FONT><FONT COLOR="#000000">_                           </FONT><FONT COLOR="#008000">" set a=""entry "" ""error"""</FONT><FONT COLOR="#000000">                           </FONT><FONT COLOR="#008000">" return a"</FONT><FONT COLOR="#000000">)),! }

}</FONT>

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 · May 28, 2018 go to post

Try so:

<<FONT COLOR="#000080">tabGroup </FONT>... <FONT COLOR="#800000">onshowTab</FONT><FONT COLOR="#000000">=</FONT><FONT COLOR="#008000">"zenThis.refreshContents(true);"</FONT><FONT COLOR="#000000">>
</</FONT><FONT COLOR="#000080">tabGroup</FONT><FONT COLOR="#000000">></FONT>

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]