#Tips & Tricks

0 Followers · 317 Posts

Pieces of experience in InterSystems Technology which solve some particular problem in elegant or unusual way.

Article Mihoko Iijima · Oct 12, 2023 1m read

InterSystems FAQ rubric

ObjectScript allows you to pass any number of arguments using arrays. Do it by adding ... after the argument name.

An example is as follows. In the example statement, the argument information is set in a global variable (a variable stored in the database) so that it can be easily checked after the method is executed.

Class TEST.ARGTEST1 Extends%RegisteredObject
{
ClassMethod NewMethod1(Arg... As %StringAs %Boolean
{
 kill ^a
 merge ^a = Arg
}
}

The result of running it in the terminal is as follows.

1
0 435
Article Megumi Kakechi · Sep 28, 2023 2m read

InterSystems FAQ rubric

In the sample below, an image file is encoded into a Base64 string in a class property, saved, decoded again with Base64, and restored to another file.

【Usage class】

Class User.test Extends %Persistent
{
Property pics As %GlobalBinaryStream;
}


【When importing】

2
1 611
Article Mihoko Iijima · Oct 5, 2023 1m read

InterSystems FAQ rubric

On Linux, use the iris command to execute a routine or method from a shell and get the return value.

For more information,  please refer to the document "About Instance Connections".

An example of a command is as follows.

iris terminal instname [arguments]

The return value of a shell script can be specified using a special variable using the Terminate() method of the %SYSTEM.Process class when the process ends, rather than by specifying an argument in the QUIT or RETURN command that is specified when a routine or method ends. Use the method of returning a value to $?.

2
1 490
Article Mihoko Iijima · Sep 21, 2023 1m read

InterSystems FAQ rubric

The meaning of each timeout value is as follows.

1. [Server response timeout]

If IRIS/Caché processing (routine or query execution) does not finish within this set time, the browser will return an error.

For example, if this value is 60 seconds and it takes 90 seconds to execute a routine/method/query, an error will occur.

2. [Queued request timeout]

For each IRIS/Caché server configured in CSP/REST, you can limit the number of processes that can run CSP/REST concurrently.

2
0 505
Article Mihoko Iijima · Sep 14, 2023 1m read

InterSystems FAQ rubric

It can be retrieved using the schema INFORMATION_SCHEMA.

INFORMATION_SCHEMA is a system schema and is not displayed by default in the SQL menu of the Management Portal.

The method to display it is as follows.

  1. Open Management Portal → System Explorer → SQL menu.
  2. Check "System" on the left of the schema drop-down.
  3. Select INFORMATION_SCHEMA from the schema dropdown.

The SQL to get the ID, field name (COLUMN_NAME), data type (DATA_TYPE), description (DESCRIPTION) for the specified table (Sample.Human) is as follows.

0
1 554
Article Mihoko Iijima · Sep 7, 2023 1m read

InterSystems FAQ rubric

You can avoid the error by specifying a stream object as the argument of %ToJSON() used when generating a JSON string from a dynamic object.

A code example is below.

USER>set temp=##class(%Stream.TmpCharacter).%New()

USER>set jsonobj={}

USER>set jsonobj.pro1=["a","b","c","d"]

USER>set jsonobj.pro2=["あ","い","う","え"]

USER>do jsonobj.%ToJSON(temp)

USER>write temp.Size
51
USER>write temp.Read()
{"pro1":["a","b","c","d"],"pro2":["あ","い","う","え"]}

See also the documentation for details.

[IRIS] Serializing large dynamic entities to streams

1
0 530
Article Ariel Glikman · Aug 28, 2023 3m read

With the world (as well as our own technology) moving to the cloud at such a fast pace it is easy (at least for myself) to get caught up in the little details. One thing I, and some clients of ours, had run into a couple of times was the necessity to specify the version of the images one plans to use with the IKO.

4
1 456
Article Mihoko Iijima · Aug 31, 2023 1m read

InterSystems FAQ rubric

By specifying the start and end values ​​of the IDs for which you want to rebuild indexes in the arguments of the %BuildIndices() method provided in the persistent class (=table) definition, you can rebuild only the indexes within that range.

For example, to rebuild the NameIDX index and ZipCode index in the Sample.Person class only for ID=10 to 20, execute the following code (the ID range is specified in the 5th and 6th arguments). 

 set status = ##class(Sample.Person).%BuildIndices($LB("NameIDX","ZipCode"),1,,1,10,20
0
0 505
Article Sylvain Guilbaud · Aug 24, 2023 1m read

It sometimes happens that due to an adverse event the AUDIT database (IRISAUDIT) has grown to such proportions that the disk it resides on is full and the daily purge cannot be expected to reclaim disk space.

As IRISAUDIT is a system database required at startup, there is no question of attempting to restart IRIS after simply deleting IRIS.DAT from the <IRIS ROOT>/mgr/irisaudit/ database, nor of hot swapping, by system manipulations trying to dismount, replace, remount, since it is simply not possible to dismount it.

IRISAUDIT database: mounting required when starting IRIS

4
0 253
Article Megumi Kakechi · Aug 10, 2023 2m read

InterSystems FAQ rubric

※Use this method if you want to compare databases that have been replicated using mirroring, shadowing, or some other mechanism.

You can use the DATACHECK utility to compare global variables. Please refer to the document below.
Overview of DataCheck [IRIS]

***

Routine comparisons use the system routine %RCMP or the Management Portal.

Below is how to use it in the Management Portal.

0
2 351
Article Megumi Kakechi · Aug 3, 2023 1m read

InterSystems FAQ rubric

You can set individual error pages for the following Web Gateway error messages/system responses:

  • server error
  • server busy
  • server unavailable
  • server timeout
  • connection closed

Settings are made on the Web Gateway Management screen ([Management Portal] > [System Administration] > [Configuration] > [Web Gateway Management] > [Configuration] > [Default Parameters]).

In the Error Page section of the Default Parameters menu, set the filename of the html page to display or the URL to redirect to when an error occurs.

  

0
1 334
Article Mihoko Iijima · Jul 20, 2023 4m read

InterSystems FAQ rubric

You can search for a specific global variable in the journal file using the ByTimeReverseOrder query of the %SYS.Journal.File class and the List query of the %SYS.Journal.Record class.

The role of each query is as follows.

A) %SYS.Journal.File query of the ByTimeReverseOrder class

You can get the journal file name. Results are returned in descending order of journal file name. 

1
1 436
Article Eduard Lebedyuk · Aug 3, 2020 3m read

InterSystems IRIS currently limits classes to 999 properties.

But what to do if you need to store more data per object?

This article would answer this question (with the additional cameo of Community Python Gateway and how you can transfer wide datasets into Python).

The answer is very simple actually - InterSystems IRIS currently limits classes to 999 properties, but not to 999 primitives. The property in InterSystems IRIS can be an object with 999 properties and so on - the limit can be easily disregarded.

13
1 817
Article Satoshi Hosoi · Jul 27, 2023 1m read

InterSystems FAQ rubric

Whether the value of a local variable is an OREF or not can be determined using $IsObject(). Let v be the variable you want to check,

$IsObject(v)=1// v is an OREF$IsObject(v)=0// v is not an OREF$IsObject(v)=-1// v is an OREF but does not point to a valid object

Note that $IsObject(v) will give an UNDEFINED error if v is undefined.

To avoid UNDEFINED errors, it is recommended to use $Get like this:

$IsObject($Get(v))
0
0 410
Article Philipp Bonin · Jun 19, 2023 3m read

OwnObjectScriptExtension

ObjectScript is a powerful language used in InterSystems products like InterSystems IRIS, enabling developers to build robust applications. To enhance the ObjectScript development experience, the OwnObjectScriptExtension is a Visual Studio Code extension that provides a range of tools and features. In this article, we will explore how the OwnObjectScriptExtension can improve your ObjectScript development workflow.

Features

Add Method Description

7
2 590
Article Luis Angel Pérez Ramos · Jul 17, 2023 10m read

Hello again everyone.

In our previous article we saw how to configure our EMPI to receive FHIR messages. To do this we installed the FHIR Adapter that InterSystems made available to us that configured a REST endpoint to which we could send our FHIR message. We would then get the message and transform it to a %String that we would send via TCP to the output of our EMPI configured in our HSPIDATA namespace.

Alright, it's time to see how we retrieve the message, transform it back to a %DynamicObject and parse it to the class used by the EMPI to store the information.

Message reception by TCP

0
0 290
Article Mihoko Iijima · Jul 13, 2023 2m read

InterSystems FAQ rubric

It can be obtained by using the Size query of the system-provided %SYS.GlobalQuery class.

See the sample code below for usage examples.
*Please check the class reference for specifying columns and parameters.

 set dir="C:\intersystems\iris\mgr\user" // IRIS.DAT(or CACHE.DAT) folder
 set rs = ##class(%ResultSet).%New("%SYS.GlobalQuery:Size")
 do rs.Execute(dir) // You can also specify a mask with the 3d parameter
 while (rs.Next()) { 
   set gname= rs.Get("Name") // global name
   set gsize= rs.Get("Used MB") // global size (MB)
   write gname," : ",gsize,!
 }
0
2 555
Article Hiroshi Sato · Jul 6, 2023 1m read

InterSystems FAQ rubric

The InterSystems ObjectScript language does not allow you to define methods of the same name with different arguments. It is generally classified as a programming language called a dynamic language.

In ObjectScript, you can freely control which arguments are used when executing a method, so unlike languages ​​such as Java, which are not dynamic programming languages, there is no need to strictly distinguish methods by the number of arguments at the compilation stage.

0
1 312
Article Ben Spead · Apr 25, 2018 6m read

NOTE:  This content was originally presented at the InterSystems Global Summit in 2014, however related topics often come up on the Developer Community so I have decided to turn this into an article for easier reference and discussion.  However, much of the content was pulled directly from the presentation slides so the article format resembles that of a PPT deck more than paragraphs.

Introduction

Teams that deal with many environments (e.g. for development, testing and production) multiplied by many systems (e.g. billing app, hr app, support app) can face a number of changes:

1
4 1108
Article Mihoko Iijima · Jun 29, 2023 3m read

InterSystems FAQ rubric

For volatile tables (tables with many INSERTs and DELETEs), storage for bitmap indexes can become inefficient over time.

For example, suppose that there are thousands of data with the following definition, and the operation of bulk deletion with TRUNCATE TABLE after being retained for a certain period of time is repeatedly performed.

0
0 309
Article Hiroshi Sato · Jun 22, 2023 1m read

InterSystems FAQ rubric

Countermeasures against SQL injection have been published on various websites, but we believe that it is possible to prevent SQL injection in applications using InterSystems SQL as well as other RDBMS by implementing these countermeasures appropriately. In addition, InterSystems Data Platform (hereinafter referred to as IRIS) incorporates several measures that make SQL injection more difficult than general RDBMS.

0
0 571
Article Megumi Kakechi · Jun 15, 2023 1m read

InterSystems FAQ rubric

Query cache can be purged programmatically using the Purge* methods of the %SYSTEM.SQL class.

*For details of each method, please refer to the following documents.

%SYSTEM.SQL class【IRIS】

%SYSTEM.SQL class

① When deleting all query caches in the system

Do $SYSTEM.SQL.PurgeAllNamespaces()


② When deleting the query cache in the namespace

// delete all cached queries in namespace
Do $SYSTEM.SQL.Purge()
// when deleting the query cache specified by date
// the following deletes the cache not used in the last 30 days

Do $SYSTEM.SQL.Purge(30) 
0
0 348
Article Hiroshi Sato · May 25, 2023 2m read

This is an article on the InterSystems FAQ site.

 1. Export API

a. Use $system.OBJ.Export() to specify individual routines to export. For example:

do $system.OBJ.Export("TEST1.mac,TEST2.mac","c:\temp\routines.xml",,.errors)

The format to specify is routine name.extension, and the extension is mac, bas, int, inc, obj.

Errors during export are stored in errors.

See the class reference %SYSTEM.OBJ for details on $system.OBJ.Export().

b. Use $system.OBJ.Export() even when exporting with wildcards. For example:

do $system.OBJ.Export("*.mac",c:\temp\allmacroutines.xml")
2
2 697
Article Mihoko Iijima · Jun 8, 2023 1m read

InterSystems FAQ rubric

Since SELECT ... FOR UPDATE is implemented in many RDBMS as a method of explicit row lock acquisition, I think there are many cases where this function is used.

This syntax is not an error for InterSystems products, but it does not acquire row locks as expected.

This article will show you how to achieve equivalent functionality.

DECLARE CURSOR C1 IS
SELECT Name FROM Person WHERE Name LIKE 'A%' FOR UPDATE
OPEN C1
LOOP FETCH C1 INTO name 
... show name
... EXIT the LOOP when finished
END LOOP
CLOSE C1
0
0 341
Article Hiroshi Sato · May 18, 2023 2m read

InterSystems FAQ rubric

Using the Config.Configuration class and SYS.Database class methods, you can create and register a namespace database from the terminal.

Below is a series of execution examples that create database file /CacheDB/AAA/cache.dat and register database AAA and namespace AAA in the configuration file (cache.cpf).
* Execute in the %SYS namespace. *

* Make sure that this script runs as the user  that is used for all IRIS processes to ensure that the directory has appropriate ownership and permissions *

3
0 428
Article David Hockenbroch · Jun 2, 2023 5m read

We are looking at what we need to do to migrate from our current usage of Zen reports to InterSystems Reports. One of the hurdles for us is figuring out ways to interact with InterSystems reports programmatically from ObjectScript routines. There is a Java API for it, but it is possible to generate a report from InterSystems reports to a stream object in ObjectScript without diving into Java by using a %Net.HttpRequest. Here is a code example, followed by an explanation:

0
0 230