Just for fun, or to see if AI matches the experts, I've asked the question to Mixtral. This is what it is explaining:

Yes, I can certainly explain the difference between %ResultSet.SQL and %SQL.Statement in Intersystems Cache ObjectScript.

%ResultSet.SQL is a class that provides a result set interface for executing SQL queries. It allows you to iterate over the rows returned by a SQL query and access the columns as properties of each row. Here's an example of how to use %ResultSet.SQL:

SET rs = ##class(%ResultSet.SQL).%Open("SELECT * FROM mytable")
DO WHILE (rs.%Next()) {
    SET column1 = rs.column1
    SET column2 = rs.column2
    // Do something with the columns
}
rs.%Close()

On the other hand, %SQL.Statement is a class that provides a statement interface for executing SQL queries. It allows you to prepare a SQL statement and then execute it multiple times with different parameter values. Here's an example of how to use %SQL.Statement:

SET stmt = ##class(%SQL.Statement).%New()
DO stmt.%Prepare("SELECT * FROM mytable WHERE column1 = :val1 AND column2 = :val2")
DO stmt.%Execute(val1, val2)
DO WHILE (stmt.%Fetch()) {
    SET column1 = stmt.column1
    SET column2 = stmt.column2
    // Do something with the columns
}
stmt.%Close()

In summary, the main difference between %ResultSet.SQL and %SQL.Statement is that %ResultSet.SQL is used for iterating over the rows returned by a SQL query, while %SQL.Statement is used for preparing and executing a SQL statement multiple times with different parameter values.

This is great Kurro!

But this is the kind of things I would definetely take advantage of embeded python to speed up the development. To send a message using python, few lines of code are needed:

import pymsteams
myTeamsMessage = pymsteams.connectorcard(url) # Initialize the connector card with webhook URL
myTeamsMessage.text("This message will end up in team") # Message content
myTeamsMessage.send()   # Send the message

Hi,

You can use this set of instructions to compact and truncate any database:

s $namespace="%SYS", Percentage=100, Databasedir="d:\whatever"
d ##class(SYS.Database).CompactDatabase(Databasedir,Percentage)
d ##class(SYS.Database).GetDatabaseFreeSpace(Databasedir, .FreeSpace)
d ##class(SYS.Database).FileCompact(Databasedir, FreeSpace, .ActualFree)
d ##class(SYS.Database).ReturnUnusedSpace(Databasedir,0,.newsize)

Hi Eduard,

This is basically same approach as mine, but straight with one single SQL operation.

Even if it works (it does, I've tested), in a database with potentially millions of records it seems to me that we would be missing background and multi-thread capacities. But by looking at the documentation I've been unable to find any method for that purpose.

Thanks for the answer, anyway! :-)

Hi Dmitriy,

Correction: it's not ODBC by JDBC

Actually, when the container is running the error is different than when it's stopped, so I guess my python script really reaches the jdbc server but somehow is not accepted.

Container running:

java.sql.SQLException: java.sql.SQLException: [InterSystems IRIS JDBC] Communication link failure: Communication error:  Server closed communication device

Container stopped:

java.sql.SQLException: java.sql.SQLException: [InterSystems IRIS JDBC] Communication link failure: S’ha refusat la connexió (Connection refused)

Answering myself:

For a system with 8 cores, we will be allowed to use maximum 16 workers. So, to be able to do it and let other processes work with the default queue, we we just need to set the global:

 s ^%SYS("WQM","MaxActiveWorkers","User.Testing")=16

so, when creating the queue it can be done attaching the workers to this queue:

  set queue=$SYSTEM.WorkMgr.%New("/multicompile=1",16,"User.Testing")