#Caché

30 Followers · 4.6K Posts

  

InterSystems Caché is a multi-model DBMS and application server. See more details here.

Documentation.

Question Alex Kogan · Jan 11, 2018

My questions are regarding ClassMethods with a private keyword tags.

When we use a wizard to add a new method, we are given a options to
select private checkbox to make it a private method as well as 
Class Method checkbox in the same time. 

1. What would be the reason and the case to select and use them both?   
2. Secondly, if there is such a case in already developed application is it
safe to remove the private tag from ClassMethod? Obviously if it's not a 
ClassMethod private tag cannot be removed as easily.

Thank you,

11
0 672
Question CJ H · Jan 11, 2018

Hi,

I want to monitor some variables in my program.

So I do this "zb *varname", however, i don't really want to get break went the program touch "varname" every time.

I only want to get break when certain conditions are meet. For example, $d(varname(1,2,3)) >  0, then break.

Is there any way to achieve this?

Thanks.

2
0 493
Question David Crawford · Jan 11, 2018

Hello everyone,

What has been the best way for you to store and retrieve session information about a user for CSP projects? I can use these methods easily:

CSP Session Management

however I'd like to know if there's a better way to keep more permanent information, or should it all be kept in a class?

Additionally, using whatever method, what would be the best way to block user access to certain portions of the website or entire pages? Such as an admin section. With normal web development this wouldn't be too difficult, but I need help connecting this into CSP terms.

Thank you!

3
0 1119
Question Nezla · Jan 1, 2018

Hi Guys,

Basically I'm looking for a sample what I can send data in aJSON format to a a webservice using an http request pls?

I've found some documentation on %Net.HttpRequest but a sample on how to connect to a Webservice and send data to it would be really helpful?

Our clients are running Cache & Ensemble 2014 

Thanks

21
0 6342
Question CJ H · Jan 9, 2018

I use zf(-2) to spawn a external a Java application in a *nix instance.

I would like to kill this process after some conditions met.

I would like to leverage $zf("kill ... ") but this requires its the pid of this child process.

So is there a way to acquire the pid for the child process when I create it ?

If not, how is the suggested way to kill this process?

Thanks.

1
0 432
Question Brian Downing · Jan 8, 2018

This is probably a very naive question but :
Is it possible to create a Windows executable file from a Cache MUMPS (COS) routine, such that the routine can be run directly from Windows ?
If so, could some kind soul direct me to a source of information that describes the process.
I am using the free Intersystems Cache installation (CachePCkit V2017.1) on Windows 10 for my own use & personal development.

Thanks

13
0 1578
Question Brian Downing · Jan 7, 2018

I am using the free Intersystems Cache installation (CachePCkit V2017.1)  on Windows 10 for my own use & personal development.
I am writing routines in Studio & running them in the Cache terminal TRM:3672 (TRYCACHE).
From a routine, how do I control print position within the terminal screen. I have tried using $X and $Y but this does not work and I cannot find what I need within the Cache terminal documentation.

Hope this question is not too simplistic for Members.
Any suggestion would be appreciated.

4
2 798
Article Evgeny Shvarov · Jan 7, 2018 1m read

Hi, Community!

Someday you find yourself having a wonderful class package which can be helpful in several projects. So it is a library package.

How to make the classes available for different namespaces in Caché? There are two ways (at least two ways familiar to me):

1. Start the name of the package with %, like %FantasticLib.SuperClass. Wrong way.

If you do that the class would be placed in %SYS and would be available in other namespaces.

This is wrong because of the two reasons:

1. The class will be wiped out with the next Caché update (as all the %SYS Namespace).

2.

8
1 693
Question Thembelani Mlalazi · Jan 5, 2018

I have read here  and tried to use the supplied examples to see what they do but keep on getting error please advice:

Method GetXMLDocFromFile(file = "C:test2.xml") As %XML.Document
{
    set reader=##class(%XML.Reader).%New()
    set status=reader.OpenFile(file)
    if $$$ISERR(status) {do $System.Status.DisplayError(status) quit $$$NULLOREF}
    set document=reader.Document
    set reNo=##class(%XML.Node).%New()//check here//how to use the below method

the error I am getting is as follows

6
0 1248
Question Thembelani Mlalazi · Jan 4, 2018

I am trying to achieve this in cache objects I am using  2014.1 here is the original code in C# and would like to convert this to cache

here is my code first c# and cache follows

     class Program
    {
        /// <summary>
        /// This function loads a XML document from the specified string.
        /// </summary>
        /// <param name="xml">Input XML string</param>
        /// <returns>XML to Json converted string</returns>
        public static string XmlToJSON(string xml)
        {
            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.LoadXml(xml);
            
            StringBuilder sbJSON = new StringBuilder();
            sbJSON.Append("{ ");
            XmlToJSONnode(sbJSON, xmlDoc.DocumentElement, true);
            sbJSON.Append("}");
            return sbJSON.ToString();
        }
        
        /// <summary>
        /// Output a XmlElement, possibly as part of a higher array
        /// </summary>
        /// <param name="sbJSON">Json string to be created</param>
        /// <param name="node">XML node name</param>
        /// <param name="showNodeName">ArrayList of string or XmlElement</param>
        private static void XmlToJSONnode(StringBuilder sbJSON, XmlElement node, 
                                            bool showNodeName)
        {
            if (showNodeName)
            {
                sbJSON.Append("\"" + SafeJSON(node.Name) + "\": ");
            }
            sbJSON.Append("{");
 
            // Building a sorted list of key-value pairs where key is case-sensitive
            // nodeName value is an ArrayList of string or XmlElement so that we know
            // whether the nodeName is an array or not.
            SortedList<string, object> childNodeNames = new SortedList<string, object>();
 
            // Add in all node attributes.
            if (node.Attributes != null)
            {
                foreach (XmlAttribute attr in node.Attributes)
                    StoreChildNode(childNodeNames, attr.Name, attr.InnerText);
            }
 
            // Add in all nodes.
            foreach (XmlNode cnode in node.ChildNodes)
            {
                if (cnode is XmlText)
                {
                    StoreChildNode(childNodeNames, "value", cnode.InnerText);
                }
                else if (cnode is XmlElement)
                {
                    StoreChildNode(childNodeNames, cnode.Name, cnode);
                }
            }
 
            // Now output all stored info.
            foreach (string childname in childNodeNames.Keys)
            {
                List<object> alChild = (List<object>)childNodeNames[childname];
                if (alChild.Count == 1)
                    OutputNode(childname, alChild[0], sbJSON, true);
                else
                {
                    sbJSON.Append(" \"" + SafeJSON(childname) + "\": [ ");
                    foreach (object Child in alChild)
                        OutputNode(childname, Child, sbJSON, false);
                    sbJSON.Remove(sbJSON.Length - 2, 2);
                    sbJSON.Append(" ], ");
                }
            }
            sbJSON.Remove(sbJSON.Length - 2, 2);
            sbJSON.Append(" }");
        }
                
        /// <summary>
        /// Store data associated with each nodeName so that we know whether 
        /// the nodeName is an array or not.
        /// </summary>
        /// <param name="childNodeNames">Collection of child nodes</param>
        /// <param name="nodeName">XML node name</param>
        /// <param name="nodeValue">XML node value</param>
        private static void StoreChildNode(SortedList<string, object> childNodeNames, 
            string nodeName, object nodeValue)
        {
            // Pre-process contraction of XmlElements.
            if (nodeValue is XmlElement)
            {
                // Convert <aa></aa> into "aa":null
                // <aa>xx</aa> into "aa":"xx".
                XmlNode cnode = (XmlNode)nodeValue;
                if (cnode.Attributes.Count == 0)
                {
                    XmlNodeList children = cnode.ChildNodes;
                    if (children.Count == 0)
                    {
                        nodeValue = null;
                    }
                    else if (children.Count == 1 && (children[0] is XmlText))
                    {
                        nodeValue = ((XmlText)(children[0])).InnerText;
                    }
                }
            }
            // Add nodeValue to ArrayList associated with each nodeName.
            // If nodeName doesn't exist then add it.
            List<object> ValuesAL;
 
            if (childNodeNames.ContainsKey(nodeName))
            {
                ValuesAL = (List<object>)childNodeNames[nodeName];
            }
            else
            {
                ValuesAL = new List<object>();
                childNodeNames[nodeName] = ValuesAL;
            }
            ValuesAL.Add(nodeValue);
        }
 
        /// <summary>
        /// This functions outputs all the stored information inside a child node.
        /// </summary>
        /// <param name="childname">Chile node name</param>
        /// <param name="alChild">Child node</param>
        /// <param name="sbJSON">Json string</param>
        /// <param name="showNodeName">Node visibility</param>
        private static void OutputNode(string childname, object alChild, 
            StringBuilder sbJSON, bool showNodeName)
        {
            if (alChild == null)
            {
                if (showNodeName)
                {
                    sbJSON.Append("\"" + SafeJSON(childname) + "\": ");
                }
                sbJSON.Append("null");
            }
            else if (alChild is string)
            {
                if (showNodeName)
                {
                    sbJSON.Append("\"" + SafeJSON(childname) + "\": ");
                }
                string sChild = (string)alChild;
                sChild = sChild.Trim();
                sbJSON.Append("\"" + SafeJSON(sChild) + "\"");
            }
            else
            {
                XmlToJSONnode(sbJSON, (XmlElement)alChild, showNodeName);
            }
            sbJSON.Append(", ");
        }
        
        /// <summary>
        /// This function makes a string safe for JSON.
        /// </summary>
        /// <param name="sIn">Input child node</param>
        /// <returns>String safe Json</returns>
        private static string SafeJSON(string sIn)
        {
            StringBuilder sbOut = new StringBuilder(sIn.Length);
            foreach (char ch in sIn)
            {
                if (Char.IsControl(ch) || ch == '\'')
                {
                    int ich = (int)ch;
                    sbOut.Append(@"\u" + ich.ToString("x4"));
                    continue;
                }
                else if (ch == '\"' || ch == '\\' || ch == '/')
                {
                    sbOut.Append('\\');
                }
                sbOut.Append(ch);
            }
            return sbOut.ToString();
        }
 
        /// <summary>
        /// This function converts Json string to XML
        /// </summary>
        /// <param name="json">Inout Json string</param>
        /// <returns>Converted XML string</returns>
        public static XmlDocument JsonToXml(string json)
        {
            XmlNode newNode = null;
            XmlNode appendToNode = null;
            string[] arrElementData;
 
            XmlDocument returnXmlDoc = new XmlDocument();
            returnXmlDoc.LoadXml("<menu />");
            XmlNode rootNode = returnXmlDoc.SelectSingleNode("menu");
            appendToNode = rootNode;
            
            string[] arrElements = json.Split('\r');
            foreach (string element in arrElements)
            {
                string processElement = element.Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim();
                if ((processElement.IndexOf("}") > -1 || processElement.IndexOf("]") > -1) &&
                    appendToNode != rootNode)
                {
                    appendToNode = appendToNode.ParentNode;
                }
                else if (processElement.IndexOf("[") > -1)
                {
                    processElement = processElement.Replace(":", "").Replace("[", "").Replace("\"", "").Trim();
                    newNode = returnXmlDoc.CreateElement(processElement);
                    appendToNode.AppendChild(newNode);
                    appendToNode = newNode;
                }
                else if (processElement.IndexOf("{") > -1 && processElement.IndexOf(":") > -1)
                {
                    processElement = processElement.Replace(":", "").Replace("{", "").Replace("\"", "").Trim();
                    newNode = returnXmlDoc.CreateElement(processElement);
                    appendToNode.AppendChild(newNode);
                    appendToNode = newNode;
                }
                else
                {
                    if (processElement.IndexOf(":") > -1)
                    {
                        arrElementData = processElement.Replace(": \"", ":").Replace("\",", "").Replace("\"", "").Split(':');
                        newNode = returnXmlDoc.CreateElement(arrElementData[0]);
                        for (int i = 1; i < arrElementData.Length; i++)
                        { newNode.InnerText += arrElementData[i]; }
                        appendToNode.AppendChild(newNode);
                    }
                }
            }
            return returnXmlDoc;
        }
 
        static void Main(string[] args)
        {
            string xml = "<menu id=\"file\" value=\"File\"> " +
                  "<popup>" +
                    "<menuitem value=\"New\" onclick=\"CreateNewDoc()\" />" +
                    "<menuitem value=\"Open\" onclick=\"OpenDoc()\" />" +
                    "<menuitem value=\"Close\" onclick=\"CloseDoc()\" />" +
                  "</popup>" +
                "</menu>";
            Console.WriteLine("Input XML string:\n");
            Console.WriteLine(xml);
            Console.WriteLine("\nOutput JSON string:\n");
            Console.WriteLine(XmlToJSON(xml)); 
            Console.WriteLine("\n================================================================================\n");
            
            const string json = @"{
                                ""foo"":""bar"",
                                ""complexFoo"": {
                                    ""subFoo"":""subBar""
                                    }
                                }";
            Console.WriteLine("Input JSON string:\n");
            Console.WriteLine(json);
            Console.WriteLine("\nOutput XML string:\n");
            Console.WriteLine(JsonToXml(json).InnerXml);
            Console.WriteLine();
        }
    }
8
0 1651
Question p rd · Jan 4, 2018

I use SoapUI 5.4.0 test Cache development web service, the parameters I need to send through SoapUI is as follows:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org">
   <soapenv:Header/>
   <soapenv:Body>
      <tem:GetPatInfo>
         <!--Optional:-->
         <tem:QueryInfo>
         <![CDATA[
<Request>
    <CardNo>100000220002</CardNo>
    <CardType></ CardType >
</Request>
]]>
</tem:QueryInfo>
      </tem:GetPatInfo>
   </soapenv:Body>
</soapenv:Envelope>

I have a Cache object:

Class ServiceTestPrd.Request.ReqPatInfo Extends (%RegisteredObject, %XML.Adaptor)
{

Property CardNo As %String;

Property CardType As %String;

}
7
0 1166
Question Tom McDevitt · Dec 21, 2017

In %Net.SSH.Session there is a method settraceMask and that will create a wireshark cap file for help with troubleshooting a connection. I dont see any class in Net.FtpSession that can be used for troubleshooting. Is there a different method that I should use?

1
0 546
Article Oleg Dmitrovich · Jan 4, 2018 5m read

Apart from the database server itself, the standard bundle of the Caché DBMS includes DeepSee, a real-time business intelligence tool. DeepSee is the quickest and the simplest way of adding OLAP functionality to your Caché application.

Another standard component is an Audit subsystem with a web interface, which has the options for expanding with your own event types and an API for using in an application code.

Below is a small example of the joint use of these subsystems that answers the following questions: who did what and when in an information system?

2
1 779
Question Joe Schra · Jan 4, 2018

Hi Everyone,

I am trying to reference a field, however, in our production environment, it can be found in the first second or third iteration. My code was only qualifying on the first iteration. I have been attempting to include all iterations, but I have come up short...below is a snippet of what I am attempting to use.  My original code simply had GetValueAt("PID:13.4") but this only referenced the first iteration. Thanks for any thoughts!

Set PID13 = pInput
1
0 326
Article Dmitry Maslennikov · Dec 4, 2015 1m read

Database Blocks Explorer for InterSystems Caché

Key features

Tree explorer
  • Shows tree of database blocks;
  • Export tree as SVG or PNG image;
  • Shows every node in the block;
  • Open any block just by clicking on node in parent block;
  • Reload block info by clicking at the same node second time;
  • Zoom in and out, fit and navigator;
  • Easy way to switch between view modes (tree/map);
Fragmentation map
  • Shows every block with the same colour for every globals;
  • Legend for globals;

Installation

Minimal supported version is 2015.3 or 2016.1.

8
0 595
Question Mikhail Khomenko · Jan 3, 2018

Hi, all!
As I know, InterSystems recommends the use of Huge Pages. And if count of Huge Pages is enough, we'll see (in cconsole.log) something like this during Cache startup:

12/29/17-14:40:50:360 (3625) 0 Allocated 4630MB shared memory using Huge Pages: 4096MB global buffers, 256MB routine buffers

But if count of Huge Pages is not enough for location of all Globals and Routines caches, Cache won't use Huge Pages.

The question is: does it exist any metrics (API) in Cache (not in OS), that can show us if Cache uses (or not) Huge Pages currently?
Thanks!

2
0 1328
Question minh nguyen · Dec 29, 2017

I'm referring to the document Using Cache with JDBC. Using this example, it sets the URL of the object ds of class CacheDataSource.

ds.setURL("jdbc:Cache://127.0.0.1:1972/SAMPLES");
My question is would you just copy and paste the URL from the login page to the string? I tried doing that and it returns an error saying "Invalid log file xyz"

Any help will be greatly appreciated! Thank you

4
0 1432
Question Guilherme Silva · Jan 3, 2018

I want to understand how this message is build:

[SYSTEM MONITOR] CPUusage Alert: CPUusage = 99, 99, 99 (Max value is 85).

Caché keep a log of cpu usage (99,99,99) and how is the frequency of check of this?

how can i chance the max value? is that possible?

Best,

4
0 1043
Question minh nguyen · Dec 29, 2017

I have a running Cache DB system that the password for DBA isn't given the default password. How should one go to reset the password without having the credentials for DBA?

3
0 661
Announcement Athanassios Hatzis · Jan 2, 2018

Connected Data London Conference

TRIADB is an emerging unique and valuable technology in NoSQL database modelling and BI analytics. The following video is from a presentation and demonstration of TRIADB prototype implemented on top of Intersystems Cache database and driven with a CLI in Python (Jupyter-Pandas). In fact this is the second time in the past year that a prototype based on this technology is implemented and demonstrated. The first one was built on top of OrientDB multi-model database and driven by a Mathematica notebook.

0
0 959
Question Lucas Fernandes · Dec 18, 2017

Hi,

Can I get "Window Size" from terminal? By command line.

Terminal > Edit > Window Size

I already tried to use 'do CURRENT^%IS', but without success. It does not return the change, for example, when the column is 132.

Is there any routine or method for this?

6
0 1083
Article David Loveluck · Dec 15, 2017 9m read

practical guide to using the tools PERFMON and MONLBL.

Introduction

When investigating performance problems, I often use the utilities ^PERFMON and ^%SYS.MONLBL to identify exactly where in the application pieces of code are taking a long time to execute. In this short paper I will describe an approach that first uses ^PERFMON to identify the busiest routines and then uses ^%SYS.MONLBL to analyze those routines in detail to show which lines are the most expensive.

The details of ^PERFMON and ^%SYS.

6
1 1337
Question Kishan Ravindran · Dec 26, 2017

What is difference between using a command $classmethod rather than just invoking them straight away?

For example if i need to call a class and its method i can just use like

do ##class(circle).radius()

rather than using

do $classmethod("circle",radius)

(I suppose both of them doing the same function i am not aware of it)

Please help me understand what is different and is there any specific usage.

Correct me if i have made mistake.

7
0 535