Alexander Koblov · Jan 26, 2019 go to post

Null in this case is not a reserved word. It’s just a name of variable that is not defined.

Alexander Koblov · Feb 28, 2019 go to post

Quoting doc: "Name indirection, argument indirection, and XECUTE commands that appear within a procedure are not executed within the scope of the procedure."

https://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=GCOS_usercode_indirxecjob

Consider method:

Class Test.test [ Abstract ]
{

ClassMethod ind()
{
	kill info

	set active = 1
	set i="active"
	set @i = "global scope"
	break
}

}

Output:

USER>do ##class(Test.test).ind()
 
 break }
 ^
<BREAK>zind+5^Test.test.1
USER 2d1>w
 
active="global scope"
<Private variables>
active=1
i="active"

Notice private variables and public variables.

Alexander Koblov · Apr 4, 2019 go to post

Lucas,

Log that you provided spans from March 19th 09:35 to March 20th 14:43.

Depending on moments when application was unavailable you need to look in different records of csp.log

For example,

  1. Exception caught in f:csp: c0000005:4600 c0000005 is the code for an access violation.

I would advise to you to try installing latest release version of CSP Gateway, or if this error still appears there, contact InterSystems Worldwide Response Center to fix this error.

  1. CSP application closed the connection before sending a complete response

This is most likely something with the code of the page "/csp/erp/system/lib/filtro.csp". It started to write some answer back and then closed the connection, for example process terminated itself with halt

  1. Configuration Error: Insufficient space in the configuration buffer Configuration block Size: 126397; Size of configuration block to insert: 55114; Space available: 68611 (Consider setting CONFIG_BUFFER_SIZE=112K (or higher) in the [SYSTEM] section of CSP.ini)

This message is self-explanatory

  1. Failed to connect to 'csp' - Reason: -8 (Server busy: Gateway's configured limits exceeded) (No Retry)

CSP Gateway can limit number of total connections to server and connections per session that it makes to Caché. See parameters "Maximum Server Connections" and "Maximum Connections per Session" here.

Generally for IIS-specifics read section "Microsoft IIS All Versions" of CSP Gateway configuration guide. And for general configuration of CSP Gateway -- chapter "CSP Gateway Operation and Configuration".

Alexander Koblov · Apr 4, 2019 go to post

David,

can you please provide provide SQL generated by the Entity Framework that is not valid and error that is generated.

Alexander Koblov · Apr 12, 2019 go to post

Jimmy, what version do you use? Try to upgrade to latest available version -- 2018.1.2 for Caché, perhaps this error is fixed there.

Alexander Koblov · May 23, 2019 go to post

Both Caché and InterSystems IRIS support ODBC. So you can connect to them from PHP via ODBC.

Alexander Koblov · Jun 13, 2019 go to post

Reason for "0.001005933" being string is not that it is less than 1, but that it's not in a canonical form.

That is -- it has integer zero before decimal point.

Put '+' before expression:

USER>Set MsgDT = "20180405000000001005933"
 
USER>Set MsgDTH = + $ZTH(($E(MsgDT,9,10)_":"_$E(MsgDT,11,12)_":"_$E(MsgDT,13,14)_"."_$E(MsgDT,15,23)),1)
 
USER>write 
 
MsgDT=20180405000000001005933
MsgDTH=.001005933
Alexander Koblov · Jun 17, 2019 go to post

You should use Locate:

Set tRegEx = "<[^>]*>"
Set htmlSnippet = "<h1>Hello1</h1><h1>Hello2</h1>"
Set regex=##class(%Regex.Matcher).%New(tRegEx)
set regex.Text = htmlSnippet
while regex.Locate() {
	write "Found ",regex.Group," at position ",regex.Start,!
}     

Also it's not possible to parse generic HTML with regular expressions (https://stackoverflow.com/a/1732454/82675). Limited subset of HTML -- maybe.

Alexander Koblov · Jun 27, 2019 go to post

Hi Nael

Not possible, as far as I know.

You can play with $stack. Something like this:

 set Result=$$MyFunc(1,.Out)
 quit
MyFunc(Param1,Param2)
 write $stack($stack-1,"MCODE"),!
 set Param2="it's all good"
 quit 1

USER>d ^test
 set Result=$$MyFunc(1,.Out)

But here you are looking at parsing plain strings, and this is error-prone.

Alexander Koblov · Jul 30, 2019 go to post

To get environment variable you can use $System.Util.GetEnviron().

And to get current folder -- $system.Process.CurrentDirectory().

Alexander Koblov · Jul 31, 2019 go to post

Not the smallest, but shortest -- 42 characters. Based on Robert's answer.

x $zwunpack("⁦㵩㨱㨱〱‰㩷⍩㴳‰䘢穩≺眠椺㔣&#x303d;∠畂空•㩷␧⁸⁩⁷‡")
Alexander Koblov · Aug 9, 2019 go to post

Hi Luis-Ángel.

Generally, if you can connect successfully then configuration is fine.

Does this happen with every query? If you try some simple query, like 'select 1', will this work ?

If yes, does your query work from Management Portal ?

Also, try enabling Audit and event Protect and check if this event is logged into Audit when this happens.

Alexander Koblov · Aug 27, 2019 go to post

Hi Oliver.

It's hard to say what's wrong with your report, as example that you provided is not standalone -- it requires table AETMON.AvailabilityLog.

At least I think, you should change

Set var(tCount,0) = rs.%Get("availabilityStatus")
Set var(tCount,1) = rs.%Get("CreatedTime")

to

Set var(0, tCount) = rs.%Get("availabilityStatus")
Set var(1, tCount) = rs.%Get("CreatedTime")

You have seriesCount="1". That is amount of lines to show on chart. Then you have seriesNames="Name1,Name2". These are names of lines. So either here you should have one name, or seriesCount should be 2.

You have seriesSize="2". This is amount of points to draw from each serie. If you indeed need only 2 points, then that's OK. However, if you remove this attribute then all points are plotted.

Generally, please see class reference for %ZEN.Report.Display.COSChart.cchart. It explains many attributes.

Below please find small sample that works. Ignore ReportDefinition. It's just there to make report run.

I hope it'll give you some hints.

Class community.ClineReport Extends %ZEN.Report.reportPage
{

Parameter DEFAULTMODE As STRING = "html";

/// This XML defines the logical contents of this report.
XData ReportDefinition [ XMLNamespace = "http://www.intersystems.com/zen/report/definition" ]
{
<report xmlns="http://www.intersystems.com/zen/report/definition"
   name="test" sql="select 1 q">
   <group name="q" breakOnField="q"/>
  </report>
}

/// This XML defines the display for this report.
/// This is used to generate the XSLT stylesheets for both HTML and XSL-FO.
XData ReportDisplay [ XMLNamespace = "http://www.intersystems.com/zen/report/display" ]
{
<report xmlns="http://www.intersystems.com/zen/report/display"
    name="test">
    <document width="8.5in"
            height="11in"
            marginLeft="1.25in"
            marginRight="1.25in"
            marginTop="1.0in"
            marginBottom="1.0in" />
    <body>
        <clineChart
                ongetData="getChartData"
                title="Availability"
                height="400px"
                width="400px"
                currYAxis="0"
                labelsVisible="true"
                lineStyle="red"
                markersVisible="true"
                plotStyle="stroke-width: 1px;"
                seriesCount="2"
                seriesNames="Name1,Name2"
                seriesYAxes="0"
                ongetLabelX="getAxisTime"
                >
            <yAxis minValue="0"
                    maxValue="100" />
        </clineChart>
    </body>
</report>
}

Method getChartData(
    ByRef data,
    chartObject)
{
    for i=1:1:10 {
        set data(0,i-1)=i * 2
        set data(1,i-1)=i * 3
    }
}

Method getAxisTime(
    val,
    yseries)
{
 quit $zdt($H-100 + val)
}

}
Alexander Koblov · Aug 29, 2019 go to post

Hi Matthias.

Try adding [Identity] to the attributes of property id in generated class.

Something like follows:

Property id As %Integer(EXTERNALSQLNAME = "id", EXTERNALSQLTYPE = 4) [ Identity, SqlColumnNumber = 2, SqlFieldName = ID ];

Hope this helps, Alexander.

Alexander Koblov · Aug 30, 2019 go to post

Hi Salma.

Check for files with extension LUT. They represent Lookup Tables. You can add these files to Studio Export.

Hope this helps, Alexander.

Alexander Koblov · Sep 6, 2019 go to post

Not possible to do this in Query. You need to use dynamic SQL.

Symbol ":" is used to indicate host variables. Host variables are treated as expressions, not as identifiers.

During query compilation host variables are replaced with placeholders.

Consider query:

SELECT FirstName, MiddleName, LastName, Email, UserType 
FROM DB.ExternalUsers
WHERE FirstName like :objSearch.FirstName
ORDER BY :objSearch.SortingField

This query is compiled as:

SELECT FirstName, MiddleName, LastName, Email, UserType 
FROM DB.ExternalUsers
WHERE FirstName like ?
ORDER BY ?

Then during runtime you supply values as follows: objSearch.FirstName = 'A%' objSearch.SortingField = 'FirstName'

And query is executed as follows:

SELECT FirstName, MiddleName, LastName, Email, UserType 
FROM DB.ExternalUsers
WHERE FirstName like 'A%'
ORDER BY 'FirstName'

Notice 'FirstName' is in quotes in ORDER BY. So you sort by literal string. That is doing nothing.

What you can do is to use expression like:

 Order by CASE :objSearch.SortingField
          WHEN 'FirstName' THEN FirstName
          WHEN 'MiddleName' THEN MiddleName
          ...
          END

Although such generic queries makes SQL Query Analyzer unable to reason what plan is better to use for this query.

Alexander Koblov · Sep 9, 2019 go to post

I'm not sure for how much this is efficient, but you can use XSLT to do the transformation.

Class CMT.XmlToCsv [ Abstract ]
{

ClassMethod transform(
	infile As %String,
	outfile As %String) As %Status
{
	Set tXSL=##class(%Dictionary.CompiledXData).%OpenId(..%ClassName(1)_"||XmlToCsv").Data
	Set tSC=##class(%XML.XSLT.CompiledStyleSheet).CreateFromStream(tXSL,.tCompiledStyleSheet)
    If $$$ISERR(tSC) Quit tSC
	quit ##class(%XML.XSLT.Transformer).TransformFileWithCompiledXSL(infile,tCompiledStyleSheet,outfile)
}

XData XmlToCsv
{
<?xml version="1.0"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="text" />
    <xsl:variable name="separator" select="','" />
    <xsl:variable name="newline" select="'&#10;'" />

    <xsl:template match="/">
        <xsl:text>Col1,Col2,Col3</xsl:text>
        <xsl:value-of select="$newline" />
        <xsl:for-each select="//Details">
            <xsl:value-of select="Col1" />
            <xsl:value-of select="$separator" />
            <xsl:value-of select="Col2" />
            <xsl:value-of select="$separator" />
            <xsl:value-of select="Col3" />
            <xsl:value-of select="$newline" />
        </xsl:for-each>
    </xsl:template>
</xsl:stylesheet>
}

}

And then call it from terminal:

set p=##class(CMT.XmlToCsv).transform("c:\temp\input.xml","c:\temp\output.txt") 
zw p

I took XSLT from https://stackoverflow.com/a/46176699/82675

Alexander Koblov · Sep 9, 2019 go to post

You need to return Status from this method.

Everything that you write inside this method is placed inside SOAP-ENV:Body element

Method override(
    proxy As %SOAP.ProxyDescriptor,
    tag As %String) As %Status
{
   Write "<request>hi</request>",!
   Quit 1
}