Question Nicky Zhu · Apr 25, 2022

Hi guys,

How to find out the number of active connections (including SQL, http, tcp and all remote connections) of an IRIS instance? A core based license is used.

I've checked the document and find %SYS.ProcessQuery.

I'm currently using this sql:

select count(distinct Pid) From %SYS.ProcessQuery
where ClientIPAddress is not null
and ClientIPAddress <> '127.0.0.1'
and ClientIPAddress <> 'localhost'
and IsGhost = '0'

Is it accurate or do we have a better option?

Thanks in advance.

4
0 468
Question Kevin McGinn · Apr 26, 2022

I wrote this COS script that I can run in a terminal session to get a view of the cache users:

set hdl = ##class(%Library.ResultSet).%New()
set hdl.ClassName = "Security.Users"
set hdl.QueryName = "Detail"
set sc = hdl.Execute()

while hdl.%Next() { do hdl.%Print() }

I know this is a bit rudimentary  but this seems to be the correct script to get users. But looking at one of the clients AIX based instances there are about 3900 users. But this script returns no results. In fact, after the execute if I issue "w hd.%Next()" it returns 0.

4
0 332
Question Timothy Leavitt · Apr 25, 2022

I have a .woff2 file I'm trying to serve over CSP.

If I set:
^%SYS("CSP","DefaultFileCharset")="UTF8"

Then it "just works" - but I'd rather not do something so heavy-handed/instance-wide, on principle. (This is for something that will ultimately be published on the Open Exchange.)

A more granular option, it seems, is described in the %CSP.StreamServer class reference:

if you need to define settings per extension (in uppercase) you can use ^%SYS("CSP","MimeFileClassify",$zcvt(ext,"U"))=$listbuild(type,bin,charset) where:

  1. type - Content Type value, e.g.
2
0 386
Question Tom Bruce · Apr 25, 2022

Hi everyone, how do you run multiple quires?

I have tried couple of different ways, but not working.

 SET sql = 2

    Set sql(1) = "UPDATE QUERY"

    Set sql(2) = "UPDATE QUERY"

    Set sqlStatement=##class(%SQL.Statement).%New()

    Set sc1=sqlStatement.%Prepare(.sql)

    If $$$ISOK(sc1)     {

       Set tResult = sqlStatement.%Execute()    

    }

    else{

        $$$LOGERROR("Failed")

    }

4
0 1976
Article Nicholai Mitchko · Apr 12, 2022 7m read

Programmatic Production Access

To Programmatically Edit Productions (interfaces) you can use a combination of the interoperability apis and SQL queries.

Current Namespace

At a high level, it is important to know the namespace and production you are working in at the moment.

// Object script 
// The active namespace is stored in this variable
$$$NAMESPACE 
// Print namespace
Write $$$NAMESPACE
# Python
import iris
# The active namespace is returned from this method
iris.utils._OriginalNamespace()
# Print namespace
print(iris.utils._OriginalNamespace())
>>> DEMONSTRATION
3
6 1111
Question Alex Cashell · Apr 22, 2022

I have a linked procedure class and SQL gateway setup and I can't seem to get any response, status or error from using the stored procedure, I think it must be something big I'm missing to not even get a status.

Can someone see what my problem is please, any help would be very much appreciated.

Class generated by linked procedure wizard:

Include %occInclude /// 
Class dbo.MrnLookup [ Not ProcedureBlock ]
{ ClassMethod MrnLookup(pp01 As %String(MAXLEN=8), ByRef mrn As %String(MAXLEN=20)) As %Integer [ ProcedureBlock = 1, ReturnResultsets, SqlName = MrnLookup, SqlProc ]
{
    if '$isobject($g(%sqlcontext)) s %sqlcontext=##class(%Library.ProcedureContext).%New() s RETURNVALUE=$g(RETURNVALUE)
 s pp01=$g(pp01)
 s mrn=$g(mrn)
 s hdbc=$$GetConnection^%apiGTW("MRNLookup")
 i hdbc="" s %msg=$$$ERROR($$$GTWCConnectionError) s %msg=$$GetErrorText^%apiOBJ(%msg) g setError
 s QHandle=$zf(-5,%SQLGateway,5,hdbc)
 i QHandle="" s %msg=$$$ERROR($$$GTWCAllocationError) s %msg=$$GetErrorText^%apiOBJ(%msg) g setError
 s err=$zf(-5,%SQLGateway,$s(%SQLGateway("-uv"):37,1:3),QHandle,"{?=call dbo.""MrnLookup;1""(?,?)}")
 i err g getError
 s err=$zf(-5,%SQLGateway,62,QHandle,1,4,1,4,10,0,10)
 s err=$zf(-5,%SQLGateway,62,QHandle,2,1,1,12,8,0,8)
 s err=$zf(-5,%SQLGateway,9,QHandle,$lb(pp01),2)
 i err g getError
 s err=$zf(-5,%SQLGateway,62,QHandle,3,2,1,12,20,0,20)
 s err=$zf(-5,%SQLGateway,9,QHandle,$lb(mrn),3)
 i err g getError
 s err=$zf(-5,%SQLGateway,4,QHandle)
 i err g getError
 s %ROWCOUNT=$zf(-5,%SQLGateway,31,QHandle)
    set tConnection = ##class(%Library.SQLGatewayConnection).%New() set tConnection.DLLHandle = %SQLGateway, tConnection.ConnectionHandle = hdbc
    set rrs = ##class(%SQL.Gateway.ODBCResultSet).%New(tConnection,QHandle)
    while $Isobject(rrs) {
        if rrs.%GetMetadata().columnCount do %sqlcontext.AddResultSet(##class(%ResultSet.Static).%New(rrs))
        set rrs = tConnection.getNextResultSet(QHandle)
    }
 s RETURNVALUE=$li($zf(-5,%SQLGateway,22,QHandle,1))
 s mrn=$li($zf(-5,%SQLGateway,22,QHandle,3))
setError ;
 If ($g(%sqlcontext)'=$$$NULLOREF) {
 Set %sqlcontext.%SQLCODE = $g(err)
 Set %sqlcontext.%Message = $g(%msg)
 Set %sqlcontext.%ROWCOUNT = $g(%ROWCOUNT)
 }
  s err=$zf(-5,%SQLGateway,16,QHandle)
 QUIT $g(RETURNVALUE)
getError ;
 s %msg=$li($zf(-5,%SQLGateway,12,hdbc,QHandle)) g setError
} }
1
0 328
Question Scott Roth · Apr 22, 2022

A question has come up that I am not finding the answer for. Does the daily purge process re-index EnsLib.HL7.SearchTable or other SQL tables?  In looking at the purge process documentation I am not seeing anything that mentions EnsLib.HL7.SearchTable. Do we have to manually constantly re-index tables that we create? For example I created another search table based off of EnsLib.HL7.Search table, will I need to constantly watch this as it grows?

1
0 369
Question Michael Davidovich · Apr 22, 2022

I am referencing the documentation here: https://docs.intersystems.com/ens201815/csp/docbook/DocBook.UI.Page.cls…

I have embedded html within a <script language="cache" runat="server"> block.  Within that I'm defining and using a macro, but it doesn't display at all. Something like:

<script language="cache" runat="server"> 
s stringData=obj.data 
#Define displayString stringData 
&html< 
<p>$$$displayString</p> 
> 
</script>
2
0 368
Question Andy Stobirski · Apr 21, 2022

Hi

I'm using an embedded SQL statement with a a cursor-based Embedded SQL query that uses host variables in the where clause, however, what I'm doing doesn't seem to work. Can anyone help?

The code I'm using is

set tMessageName = "AssessmentsMessage"
set tIdentifier = "SectionCode" 
set ID = 0
&sql(
    Declare IDs Cursor For 
    select  %ID
    INTO :ID
    from GMECC_DocmanConnect_Tables.ParisConnecMessagetSettings
    Where  MessageName = :tMessageName
    and Identifier = :tIdentifier
)

&sql(Open IDs) For {
   &Sql(fetch IDs) If SQLCODE Quit // SQLCODE = 100, now rows found
       w !, ID 
       If $$$ISERR(tSC) Quit
} &Sql(Close IDs)
15
0 457
Question Megumi Kakechi · Apr 21, 2022

I tried to convert IRIS globals to pandas dataframe.

I can do it as follows if there are no Japanese included in globals,

USER>zw ^ISJ2
^ISJ2=4
^ISJ2(1)=$lb("Name","Age","Address")
^ISJ2(2)=$lb("Sato","50","Tokyo")
^ISJ2(3)=$lb("Kato","40","Osaka")
^ISJ2(4)=$lb("Ito","30","Kyoto")
 
USER>do $system.Python.Shell()
 
Python 3.9.5 (default, Jan 31 2022, 17:55:36) [MSC v.1927 64 bit (AMD64)] on win32
Type quit() or Ctrl-D to exit this shell.
>>> mysql = "select name,value from %library.global_get('user','^ISJ2',,2,2)"
>>> resultset = iris.sql.exec(mysql)
>>> dataframe = resultset.dataframe()
>>> print (dataframe)
       name                        value
0     ^ISJ2                            4
1  ^ISJ2(1)  $lb("Name","Age","Address")
2  ^ISJ2(2)     $lb("Sato","50","Tokyo")
3  ^ISJ2(3)     $lb("Kato","40","Osaka")
4  ^ISJ2(4)      $lb("Ito","30","Kyoto")
>>>
2
0 411
Question Megumi Kakechi · Apr 18, 2022

How can I get the Python error object(exception return value) from the embedded python method?
I have an embedded Python method like as below;

ClassMethod test2() As XXX [ Language = python ]
{
   try:
    a=1/0
   
   except Exception as ex:
    print("Exception: %s" % str(ex))
    return ex
}

I'm not sure what kind of return type to set for this classmethod.   "As XXX" <--
I tried to set "ClassMethod test2() As %Exception.PythonException [ Language = python ]"
However, I got the following return value when I run the method in the IRIS terminal.

USER>set st= ##class(User.PythonTest).test2()
Exception: division by zero
USER>zw st
st=4@%SYS.Python ; division by zero ; <OREF>
USER>
9
2 985
Question Kevin McGinn · Apr 15, 2022

When looking at the "Current License Usage Summary" web page, there is a line for both local and distributed "Maximum Connections". I have scrutinized every class that seems reasonable to contain this information but have found nothing that matches the values on the web page. I do not believe these are related to license specifically though I did review all of the potential attributes of the license related classes to no avail.

2
0 366
Article Victor Sanner · Apr 20, 2022 2m read

Hi,

I have wrote an article about how to install the intersystems cache driver in a Docker container, and then deploy it using Azure Functions: 

How to run a (Python) Azure Function as a Docker container & Deploy it using Bicep | Victor Sanner
This might be useful to others, especially the dockerfile which I have copied below. This builds a debian docker container and installs the Intersystems Cache driver, which python can then use :)

To enable ssh & remote debugging on app service change the base image to the one below
# FROM mcr.microsoft.com/azure-functions/python:3.0-python3.6-appservice
FROM mcr.microsoft.com/azure-functions/python:3.0-python3.6

ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
    AzureFunctionsJobHost__Logging__Console__IsEnabled=true

# Add ODBC Driver requirements 
RUN apt-get update \
 && apt-get install unixodbc -y \
 && apt-get install unixodbc-dev -y \
 && apt-get install freetds-dev -y \
 && apt-get install freetds-bin -y \
 && apt-get install tdsodbc -y \
 && apt-get install --reinstall build-essential -y

# add pyodbc requirements
RUN apt-get install python-pyodbc -y

#copy the driver to container
COPY /Driver /usr/lib/intersystems/odbc

#run install script
RUN /usr/lib/intersystems/odbc/ODBCinstall

#copy the odbc configuration file to the container
COPY odbc.ini /etc/intersystemsodbc.ini

#make the odbc library aware that we have added a new driver
RUN odbcinst -i -d -f /etc/intersystemsodbc.ini

#symlink the odbc driver, not sure if its required
RUN ln -s /usr/lib/x86_64-linux-gnu/libodbccr.so.2.0.0 /usr/lib/x86_64-linux-gnu/odbc/libodbccr.so

#copy the Azure Functions project to the docker image
COPY . /home/site/wwwroot

#install the python libraries as you would usually do
RUN cd /home/site/wwwroot && pip install -r requirements.txt
0
2 721
Question Nezla · Apr 18, 2022

Hi Guys,

I know that there a way to view global content from the Terminal rather the SMP but I can't remember the command, I think it's something like D ^Global or something !?

Thanks

6
0 786
Article Sylvain Guilbaud · Apr 19, 2022 2m read

Kong provides an open source configuration management tool (written in Go), called decK (which stands for declarative Kong)

  • Check that decK recognizes your Kong Gateway installation via deck ping
deck ping   
Successfully connected to Kong!
Kong version:  2.3.3.2-enterprise-edition
  • Export Kong Gateway configuration to a file named "kong.yaml" via deck dump
deck dump
  • After modifying the kong.yaml, show the differences via deck diff
deck diff
updating service alerts  {
   "connect_timeout": 60000,
-  "host": "172.24.156.176",
+  "host": "192.10.10.18",
   "id": "3bdd7db4-0b75-4148-93b3-2ff11e961f64",
   "name": "alerts",
   "path": "/alerts",
   "port": 50200,
   "protocol": "http",
   "read_timeout": 60000,
   "retries": 5,
   "write_timeout": 60000
 }

Summary:
  Created: 0
  Updated: 1
  Deleted: 0
0
0 829
Question Lorenzo Scalese · Apr 16, 2022

Hi Community,

When we terminate a process that is in a transaction, the system (fortunately) performs a rollback.

As part of some troubleshooting, I'm wondering if there's a way around this behavior to avoid rollback (or force commit) before termination.

Recently we had an issue on a test server with a process stuck in a huge transaction (around 100GB).

The out-of-control process was suspended and then terminated causing a rollback.

In the case of a test server, this is not really a problem.

6
1 771