I have a query text that I need to execute and return results as xml.
It may be an SQL query or an MDX query. Is there some easy way to determine which one is it?
Any ideas?
I have a query text that I need to execute and return results as xml.
It may be an SQL query or an MDX query. Is there some easy way to determine which one is it?
Any ideas?

In this article, I'd demonstrate how you can visualize the usage of Ensemble Workflow with DeepSee (tested on 2015.1 and later).
How can I localize arbitrary column name in DeepSee pivot?
If a column name is a dimension or a measure I can localize using architect following this guide.
But what about some random string?
I have tried setting:
as a Caption, but every option simply displays as is.

Hi, Community!
And so I continue with publishing of the tasks for the Final round of InterSystems Contest on InterSystems Caché and DeepSee as a part of IT Planet Student Championship in Sochi. This year we had about 2 000 participants in InterSystems Contest.
One of the tasks for the finals was to crack the black box and another to output 9876543210!
Here's the next task: gravity!
I have a class with text property, which contains html text (usually pieces, so it may be invalid), here's a sample value:
<div moreinfo="none">Word1 Word2</div><br> <a href = "123" >Word3</a>
When I add iFind index on text, there are at least two problems:
How can I pass plaintext into iFnd index?
Hi, Community!
And so I continue with publishing of the tasks for the Final round of InterSystems Contest on InterSystems Caché and DeepSee as a part of IT Planet Student Championship in Sochi. This year we had about 2 000 participants in InterSystems Contest.
One of the tasks for the finals was to crack the black box!
I'm using %SOAP.WebRequest to send SOAP requests:
Currently the XML I send looks like this:
<?xml version="1.0" encoding="UTF-8" ?> <SOAP-ENV:Envelope xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'> <SOAP-ENV:Header> <SomeCustomHeader/> </SOAP-ENV:Header> <SOAP-ENV:Body><SomeCustomBody/></SOAP-ENV:Body> </SOAP-ENV:Envelope>
However, I want XML to be generated differently:
How can I tweak XML generation to achieve that?
In the first article I discussed testing and debugging Caché web applications with external tools. Second part would cover Caché tools.
They are:
Hi, Community!
Last weekend we held the Final of InterSystems Contest on InterSystems Caché and DeepSee as a part of IT Planet Student Championship in Sochi. BTW, this year we had about 2 000 participants in InterSystems Contest.
One of the tasks for the finals was to solve the following with Caché ObjectScript and use the minimum code.
Write a method that would return the string 9876543210, however cls code should not contain numbers 0-9.
The goal is to write the shortest method.
How do I write DDL script for collection properties?
For example I want to create the following class:
Class SQLUser.Person {
Property Name As %String;
Property FavoriteColors As list Of %String;
}My DDL script looks like this:
CREATE TABLE Person (Name varchar(50), FavoriteColors ???)I'm aware of two ways to get list of files in a dir:
set dir = "C:\temp\" set rs = ##class(%File).FileSetFunc(dir, , , 1) do rs.%Display()
and:
set dir = "C:\temp\"
set file=$ZSEARCH(dir_"*")
while file'="" {
write !,file
set file=$ZSEARCH("")
}Yet they bot return only files and directories in a current directory, but not files in subdirectories.
I suppose I call one of these recursively, but maybe there's a better solution?
I have a business service and I want to know when did the current business service job started.
Is there a way to get this information from Ensemble?
I heed to his a callback method after all REST call. I have already found a method to call before REST call, but after eludes me. Here's the code:
Class Test.REST Extends %CSP.REST
{
XData UrlMap [ XMLNamespace = "http://www.intersystems.com/urlmap" ]
{
<Routes>
<Route Url="/:classname" Method="GET" Call="TEST" Cors="true"/>
</Routes>
}
/// This method Gets called prior to dispatch of the request. Put any common code here
/// that you want to be executed for EVERY request. If pContinue is set to 0, the
/// request will NOT be dispatched according to the UrlMap. If this case it's the
/// responsibility of the user to return a response.
ClassMethod OnPreDispatch(pUrl As %String, pMethod As %String, ByRef pContinue As %Boolean) As %Status
{
set ^CacheTemp.DBG($i(^CacheTemp.DBG)) = "OnPreDispatch"
set pContinue = $$$YES
quit $$$OK
}
ClassMethod TEST(name) As %Status
{
set ^CacheTemp.DBG($i(^CacheTemp.DBG)) = "TEST"
//w 1/0
quit $$$OK
}
/// Issue an '500' error and give some indication as to what occurred
ClassMethod Http500(pE As %Exception.AbstractException) As %Status
{
set ^CacheTemp.DBG($i(^CacheTemp.DBG)) = "Http500"
quit ##super()
}
/// Doesn't work
ClassMethod OnPostHTTP() [ Abstract, ServerOnly = 1 ]
{
set ^CacheTemp.DBG($i(^CacheTemp.DBG)) = "OnPostHTTP"
}
/// Doesn't work
ClassMethod OnPostHyperEvent(class As %String, method As %String) As %Status [ ServerOnly = 1 ]
{
set ^CacheTemp.DBG($i(^CacheTemp.DBG)) = "OnPostHyperEvent"
quit $$$OK
}
}In this article I'll cover testing and debugging Caché web applications (mainly REST) with external tools. Second part covers Caché tools.
You wrote server-side code and want to test it from a client or already have a web application and it doesn't work. Here comes debugging. In this article I'll go from the easiest to use tools (browser) to the most comprehensive (packet analyzer), but first let's talk a little about most common errors and how they can be resolved.
Maybe someone has a logger for incoming CSP requests and willing to share? Debugging high traffic HTTPS application and wireshark just doesn't cut it sometimes. So I thought I'd ask here. I'm especially interested in getting raw stream of incoming request.
I need to convert timestamp into HTTP-date as defined in section 3.3.1 of [RFC2068]. HTTP-Date can have several representations, but preferable view is defined by RFC 822, updated by RFC 1123 and looks like this:
wkday "," SP date1 SP time SP "GMT"
Here's an example of HTTP-date value:
Sun, 06 Nov 1994 08:49:37 GMT
The problem I encountered, is that if server locale is not English, then $zd, $zdt and TO_CHAR return localized names of weekday and month (i.e: Вос). Is there a way to get English names of weekday and month regardless of server locale?
Just checked TO_CHAR and it also calls $zd.
If you're using Firefox, you probably know that there are search engine addons that allow us to use website search directly. Now, docs.intersystems.com is also available as a search engine here. Here's how it looks:

Let's say I need to process these urls in one REST method:
http://host:port/REST/arg1/arg2/arg3 http://host:port/REST/arg1/arg2/ http://host:port/REST/arg1/arg2 http://host:port/REST/arg http://host:port/REST/
Currently I need to define URL Map like this (assuming /REST web app):
XData UrlMap
{
<Routes>
<Route Url="/:arg1" Method="GET" Call="GET"/>
<Route Url="/:arg1/:arg2" Method="GET" Call="GET"/>
<Route Url="/:arg1/:arg2/" Method="GET" Call="GET"/>
<Route Url="/:arg1/:arg2/:arg3" Method="GET" Call="GET"/>
</Routes>
} Is there a way to get all these URLs in one route:
In my previous article, we reviewed possible use-cases for macros, so let’s now proceed to a more comprehensive example of macros usability. In this article we will design and build a logging system.
Logging system is a useful tool for monitoring the work of an application that saves a lot of time during debugging and monitoring. Our system would consist of two parts:
Let's say I have two classes: A and B. They share no common parent except %SystemBase. But these classes have some properties with the same name (type may be the same or not):
Class A {
Property data As C;
Property data2;
}Class B {
Property data As D;
Property data3;
}I need to automatically convert object of class A into object of class B. I'm planing to write a class generator that generates a separate class that converts A to B. It would work like this:
1.
The task of handling office documents, namely docx documents, xlsx tables and pptx presentations is quite complicated. This article offers a way to parse, create and edit documents using only XSLT and ZIP.
Why? docx is the most popular document format, so the ability to generate and parse this format would always can be useful. The solution in a form of a ready-made library, can be problematic for several reasons:
In this article, I would use only basic tools for work with the docx documents.
I have a web application with html, css, js files (no ZEN/CSP).
Problem: after I update them on a server, Caché still servers old and cached version (browser Cache is disabled).
There is a manual cache purge in Gateway Settings, of course, but is there an automatic solution?
I'll be okay with disabling cache server-wide, but an application-wide solution would be better.
I don't want to host web app on a separate web server.
Here's my web app config:

I created a new class DSW.Addons.htmlViewer:
Class DSW.Addons.htmlViewer Extends %DeepSee.Component.Portlet.abstractPortlet
{
Property Data As %String;
ClassMethod %OnGetPortletSettings(Output pInfo As %List, ByRef pSettings) As %Status
{
Kill pInfo
Set pInfo(1) = $lb("Data", , , "Data", "Data setting")
Quit $$$OK
}
}It's a ZEN component and DeepSee portlet. It's immediately available in the namespace I created it in. DSW package is mapped to %ALL and to Samples, but if I try to create a widget with this portlet I get ZEN class not found error.
In this article I'll show you how you can easily convert between many different document formats, these to be precise:
and many more, check out this table. We'll use LibreOffice as a conversion engine.
I want to override getter for a serial property as a whole, because getter code depends on a class in which a property is defined.
Let's say I have CS.Serial as a serial class:
Class CS.Serial Extends %SerialObject
{
Property Year As %Integer;
Property Month As %Integer;
}And CS.Persistent as a persistent class:
Class CS.Persistent Extends %Persistent
{
Property data As CS.Serial [ SqlComputeCode = {set {*} = ##class(CS.Persistent).dataGetStatic()}, SqlComputed, Transient ];
/// data getter method in object context
Method dataGet() As CS.Serial
{
return ..data2GetStatic()
}
/// data getter method in SQL context
ClassMethod dataGetStatic() As CS.Serial
{
return $lb($lb("2017","01"),"CS.Serial")
}
}This little guide would help you start running Ensemble REST services in no time.
Recently I started working with GitLab - GitHub self-hosted foss alternative. So far so good, liked the UI, ease of administration, and available functionality (I was on Phabricator previously, and still use it for repo mirroring).
GitLab has GitLab CI (GitLab Continuous Integration) which looks promising (pluggable docker/vm/ds to run code) , but I wondered if someone uses it already and can share scripts for it?
In addition to its general security, Caché offers SQL security with a granularity of a single row. This is called row-level security. With row-level security, each row holds a list of authorized viewers, which can be either users or roles. By default access is determined at object modification Some time ago I became interested in determining row-level security at runtime. Here's how to implement it.
I use DataGrip (JDBC client) to query Caché server via JDBC.
The problem I encountered, is that if I wait 10 or more minutes between queries I get an error:
[08S01][461] Communication link failure: Socket closed
To fix that I need to disconnect and connect to server again. Is there a JDBC timeout setting somewhere I can change?
As stated, I have ZEN report, which I want to render in displayxlsx mode.
Currently it looks like this:

I want it to look like this:
Differences are:
My report definition looks like this:
XData ReportDefinition [ XMLNamespace = "http://www.intersystems.com/zen/report/definition" ]
{
<report xmlns="http://www.intersystems.com/zen/report/definition"
name="MyReport"
sql="SELECT TOP 10 Name,DOB,Age FROM Sample.Person"
runtimeMode="0">
<group name="Person">
<attribute name="name" field="Name"/>
<attribute name="dob" field="Dob"
expression="..ToExcelDate(%val)"/>
<attribute name="age" field="Age"/>
</group>
</report>
}