Question Norman W. Freeman · Feb 8, 2023

I use the following code (which is a simplified version of what happen on a server) :

tstartfor I=1:1:N {
  set test = ##class(Test.Test).%New()
  set test.ID = I
  do test.%Save() //create a "Exclusive_e->Delock" lock on ^Test.TestD(..)
}
hang 5tcommit//locks are removed here

Test.Test is a persistent class that inherit from %Persistent :

Class Test.Test Extends %Persistent
{
   Property ID As%Integer [ Required ];
   Index IDKEY On ID [ IdKey ];//...      
}
6
0 334
Question Norman W. Freeman · Jan 19, 2023

I have noticed that the way the nodes are ordered is different between 2 different environments.

If I create the following global :

set^TEMP("Z")=1set^TEMP("Ä")=1

Then I dump it with zwrite, I get this (which is expected):

^TEMP("Z")=1^TEMP("Ä")=1

However, on another machine, it gives me this :

^TEMP("Ä")=1^TEMP("Z")=1

The same goes for the following command (which return 0 or 1, depending environment) : 

write"Z"]]"Ä"

Both are running Windows 10, but one is running IRIS 2021.1, the other CACHE 2017.2.2.

5
0 251
Question Norman W. Freeman · Nov 29, 2022

I got an error that occurs inside %CSP.Broker. That class is located inside %SYS namespace.

I tried lot of things (including checking system logs) but ultimately what would really help would be to be able to modify that class to add my own logs into it.

If I try to modify it, I got this error message: 

Item '%CSP.Broker' is mapped from a database that you do no have write permissions on.

5
0 556
Question Norman W. Freeman · Oct 12, 2022

I use the following code to check the last modified date of file which is on a network shared folder (eg: "\\someserver\subfolder\foobar.txt")

set file = ##class(%File).%New(filePath)
set lastModifiedDate = file.DateModified //might hang up for a very long time set file = "" //close file

if the file is not available or does not exists, DateModified property return a negative value (which is fine). I use that property to quickly check if file has been modified and need to be imported.

2
0 886
Question Norman W. Freeman · Jul 29, 2022

I have migrated one project from CACHE to IRIS that contains lot of classes that inherit from BI (Business Intelligence).

Usually it looks like this : 

Class User.Foo Extends (%Library.Persistent, %XML.Adaptor, %BI.Adaptor)
{
}

I was wondering if there is an equivalent of those classes in IRIS, and, if not, if there is a workaround that would allow me to at least le me compile those classes.

I tried to create an empty class like that : 

Class%BI.Adaptor
{
}

But I got the following error in Studio : 

5883    Item '%BI.Adaptor' is mapped from a database that you do not have write permission on.

3
1 554
Question Norman W. Freeman · Jul 1, 2022

We recently migrated to IRIS. Before, the CACHE.EXE executable could be invoked from a batch file directly : 

C:\InterSystems\Cache\bin\cache.exe -s C:\InterSystems\Cache\mgr -U %SYS

This will display the following in console : 

Node: DESKTOP-8H4B321, Instance: CACHE

USER>

Additionally, the pipe instruction can be used to redirect some commands directly

echo write 50 | C:\InterSystems\Cache\bin\cache.exe -s C:\InterSystems\Cache\mgr -U %SYS

I am looking for the same thing in IRIS. If I do the same command line with IRIS executable, I got an error : 

Invalid argument to IRIS : -s

5
0 675
Question Norman W. Freeman · Jun 28, 2022

I want to call a method which is in %SYS namespace : 

set NS = $NAMESPACEZN"%SYS"do ##class(Config.MapGlobals).Delete(...)
ZN NS

In reality code is even more complex (eg: need a try catch block to make sure namespace is switched back even if there is some error).
Is it possible to do this without changing current namespace ?
For example (does not work) :

do ##class(%SYS.Config.MapGlobals).Delete(...)
4
0 694
Question Norman W. Freeman · Jan 17, 2022

I would like to create a toolbar button in Cache Studio. After clicking on it, it would run a custom command (eg: to execute a routine that will clean a global).

I took a look at dialog that is shown after right clicking on a toolbar in Studio, then choosing "Customize" but AFAIK there is nothing there that allow such a thing.

I know it's possible to customize menu items by extending %Studio.SourceControl.Base class, is there something similar for toolbars ?

Here is some base code example (based on Danny Wijnschenk answer) :

6
0 337
Question Norman W. Freeman · Oct 29, 2021

I have a workstation with a CACHE instance up and running.

On that same workstation there is also an instance of IRIS (fresh install). I would like to migrate manually the CACHE database to IRIS (ideally, all globals, routines and classes).

What I tried is to copy C:\InterSystems\Cache\mgr\CACHE.DAT to C:\InterSystems\IRIS\mgr\IRIS.DAT (after shutting down both instances) but it does not work.

I got the following message :(112) The service for the IRIS instance did not start.

6
2 1343
Question Norman W. Freeman · Oct 8, 2021

I use the following code to start a start a job :

Class MyClass Extends (...)
{
    ClassMethod Foo()
    {
       job $CLASSMETHOD("MyClass","MyMethod") //take forever depending hardware
    }

    ClassMethod MyMethod()
    {
       //do database related stuff
    }
}

On local environment, calling Foo() is instantaneous (a few ms). On production/test servers (which have much better hardware than local) calling this function is slow and take between 200 ms to 800 ms. Obviously starting a new job with "job" command take lot of time on those environments.

3
0 326
Question Norman W. Freeman · Oct 5, 2021

I would like to know if an encrypted caché database can run significantly slower than a normal "unencrypted" database, in a way that is noticeable to the end user (e.g. slower response time for most pages, especially the ones that rely on read/writing to globals).

I searched in Intersystems knowledge base and couldn't find anything related. I'm looking for possible before/after benchmarks.

3
0 340
Question Norman W. Freeman · Aug 27, 2021

In Caché, it's possible to iterate a local array using $QUERY() :

set a("foo") = 50
set a("bar") = 30

set key = "a"
for
{
     set key = $QUERY(@key)
     quit:key="" 
     write key_" = "_@key
}

This code works perfectly, unless it's called in a job (eg: a routine called by the JOB command).

In that case, $QUERY will return an empty string. It's like the array cannot be referenced anymore by simply using it's name.
It works using $ORDER(a("")) but I would like to use $QUERY if possible (because my array has several dimensions and it would require several for loops).

3
1 412
Question Norman W. Freeman · Aug 19, 2021

I have a CSP page that throw a "414 error - Request-URI Too Long" when I put lot of text (eg : 10000 characters) into a field of a submitted form. The form is submitted using POST method.

Based on some experiments I made, it seems the max size of a URL is around 8200 characters.

What is the official limit, and is there a way to increase it ? I searched in the documentation but couldn't find anything.

5
0 3951
Question Norman W. Freeman · May 26, 2021

I have some code in a mac routine that use indentation and the "." character : 
 

 IF condition1 DO
     .WRITE YCR,...
     .WRITE YCR,...
     .WRITE YCR,...

I would like to add a try / catch block between the write statements.
I can't refactor the whole code and use indentation with curly braces instead (there is too much code, not written by me)

I have tried the following but it does not work (it compiles, but code stop running right before the try keyword)

 IF condition1 DO
    try {
        .WRITE YCR,...
        .WRITE YCR,...
        .WRITE YCR,...
    }
    catch {
    }
2
0 349
Question Norman W. Freeman · Dec 24, 2020

I have implemented a web service that inherit from %SOAP.WebService

It exposes classes with string properties : 

Class Employee Extends (%RegisteredObject, %XML.Adaptor) [ ProcedureBlock ]
{

Parameter XMLNAME = "Employee";
Parameter XMLSEQUENCE = 1;

Property FirstName As %String(MAXLEN = "", XMLNAME = "FirstName") [ Required ];
Property LastName As %String(MAXLEN = "", XMLNAME = "LastName") [ Required ];
...

Here is the issue: those properties are filled from a huge Caché database which contains forbidden XML characters (usually control characters in the 0-31 range).

1
0 676
Question Norman W. Freeman · Oct 1, 2020

If a global node contains special characters, (eg : a line returns), it will be displayed like this in Portal ("System > Globals > View Global Data" panel) :

^A(1) = "this is"_$c(13,10)_"a test"

I would like to export global data to a txt file using a similar format.

I already wrote the main code (that loops on all nodes and dump them to file), the problem is how to handle special characters.
For the moment I replace them manually one by one. It works, but it's far from perfect :

5
0 1967
Question Norman W. Freeman · Sep 23, 2020

When you export entities like classes, routines, globals in Cache Studio, you usually end up with XML files that looks like this : 

<?xml version="1.0" encoding="UTF-8"?>
<Export generator="Cache" version="25">
    <Class name="base.monitoredpage">
        <Abstract>1</Abstract>
        <Super>%CSP.Page</Super>
        <TimeCreated>63439,41357.461462</TimeCreated>
        <Parameter name="ENCODED">
            <Default>0</Default>
        </Parameter>
        ...
8
0 1402