#Caché

30 Followers · 4.6K Posts

  

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

Documentation.

Article Ben Spead · Aug 25, 2016 4m read

Background

Caché 2016.1 introduced some very powerful JSON features.  Unfortunately, the syntax used in the 2016.1 release is going to be changed in the 2016.2 release to bring it closer to Caché ObjectScript syntax.  This will mean that code that works in 2016.1 may not be forwards compatible.   See this announcement and this article for more details about the changes.

11
0 2170
Article Sylvain Guilbaud · Oct 4, 2016 6m read

This sample class will add parameter DSINTERVAL to each class containing the parameter DSTIME

To execute it from a Terminal :


SAMPLES>d ##class(adm.param).add(,,1)
[SAMPLES] parameter DSINTERVAL=5 added to class DeepSee.Study.CityRainfall (via adm.param)
[SAMPLES] parameter DSINTERVAL=5 added to class HoleFoods.Transaction (via adm.param)
[SAMPLES] parameter DSINTERVAL=5 added to class News.DeepSee.NewsArticle (via adm.param)
DSINTERVAL parameter was added to 3 classes

Class adm.param [ Abstract ]
{

/// this class will add DSINTERVAL parameter to each class containing DSTIME
/// in order to synchronize a cube that is based on a source table on a mirror system
/// see: http://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=D2IMP_ch_current#D2IMP_current_dstime_enabling
ClassMethod add(name As %String = "DSINTERVAL", value As %String = "5", verbose As %Boolean = 0) As %Status
{
    set sc = $$$OK
    try {
        set statement = ##class(%SQL.Statement).%New()
        // %Dictionary classes are useful to select classes based on their content
        // here we use %Dictionary.ParameterDefinition class which contains all the parameters defined in all classes
        // then we will open the parent class to add the missing parameter
        set query="SELECT a.parent "
                 _"FROM %Dictionary.ParameterDefinition a "
                 _"WHERE a.name='DSTIME' "
                 _"AND substr(a.parent,1,1)<>'%' "
                 _"AND NOT EXISTS (SELECT null "
                 _"FROM %Dictionary.ParameterDefinition b "
                 _"WHERE b.name='"_name_"' and b.parent=a.parent)"
        set sc = statement.%Prepare(query)
        quit:$$$ISERR(sc)
        set classes="",nb=0
        set rs = statement.%Execute()
        while (rs.%Next(.sc)) {
            quit:$$$ISERR(sc)
            if (rs.parent '="") {
                // opening of the parent class 
                set class = ##class(%Dictionary.ClassDefinition).%OpenId(rs.parent)
                if $IsObject(class) {
                    // creating the new parameter
                    set param=##class(%Dictionary.ParameterDefinition).%New()
                    set param.Name=name
                    set param.Default=value
                    // adding the parameter to the parent class
                    do class.Parameters.Insert(param)
                    set sc=class.%Save()
                    // if parent class is successfully saved set the following message
                    set:sc msg="["_$namespace_"] parameter "_name_"="_value_" added to class "_rs.parent_" (via "_..%ClassName(1)_")",severity=0
                    // if parent class is not saved set the following message
                    set:'sc msg="["_$namespace_"] ERROR while saving "_rs.parent_" after having added the parameter "_name_"="_value_" (via "_..%ClassName(1)_") :"_$system.Status.GetErrorText(sc),severity=1
                    // if verbose=1 write the message to the terminal
                    write:verbose msg,!
                    // write the message to cconsole.log
                    do ##class(%SYS.System).WriteToConsoleLog(msg,verbose,severity)
                    // add the class name to compile 
                    set classes(rs.parent)="",nb=$increment(nb)
                }
            }
        }
        set:nb=0 msg=name_" parameter was not added to any class"
        set:nb=1 msg=name_" parameter was added to "_nb_" class"
        set:nb>1 msg=name_" parameter was added to "_nb_" classes"
        write:verbose msg,!
        // compile all modified classes 
        if nb>0 { 
            set sc=$system.OBJ.Compile(.classes,"ck"_$select(verbose:"d",1:"-d"))
            set:sc msg="["_$namespace_"] modified "_$select(nb=1:"class",1:"classes")_" successfully compiled",severity=0
            set:'sc msg="["_$namespace_"] ERROR while compiling classes : "_$system.Status.GetErrorText(sc),severity=1
            do ##class(%SYS.System).WriteToConsoleLog(msg,verbose,severity)
            write:verbose msg,!
        }    
    }
    catch(ex) {
        set sc = ex.AsStatus()
        set msg="["_$namespace_"] error while executing "_..%ClassName(1)_":add("_name_","_value_") : "_ex.DisplayString(),severity=1
        write:verbose msg,!
        do ##class(%SYS.System).WriteToConsoleLog(msg,1,severity)
    }
    return sc
}

}
6
1 1175
Question William Proctor · Sep 30, 2016

Good Morning and thanks in advance for all replies.  I have created a PowerShell script for backing up CACHE and all related files to be run on a nightly basis.  My script works as long as the Unknownuser has %all access which is not acceptable in our production environment.  I have tried every format I can thank of to get the script to use a specific id with no luck.  How can I get this command to run under a specific id? 

..\bin\cache -s. -U%SYS "##Class(Backup.General).ExternalFreeze() <d:\backup\login.scr" 

The file just has

userid`r`n
​password`r`n

`r

5
0 779
Article Mike Kadow · Sep 15, 2016 2m read

NewBie's Corner Session 27 Traversing A Global with $Order Part 1

Welcome to NewBie's Corner, a weekly or biweekly post covering basic Caché Material.

Traversing A Global

Perhaps the most difficult concept in Caché/MUMPS is its Global Structure. This session and several that follow it deals with the Global Structure. However, just presenting the material will not guarantee your understanding of it. You must experiment with the data and concepts that are presented.

In this session, we are going to create a small Global of three levels deep, and then show the code to Traverse the Global.

20
0 929
Article Mike Kadow · Sep 23, 2016 5m read

NewBie's Corner Session 28 Various Methods to Traverse a Global

Welcome to NewBie's Corner, a weekly or biweekly post covering basic Caché Material.

Judging from the number of responses to Session 27 Traversing A Global, developers are passionate about their methods. I am not here to judge the merit of the various methods.

Over the next few pages I will demonstrate a number of methods to Traverse a Global. If you don't already have a favorite they may help you pick one.

I will repeat the method from Session 27 just to have all methods in one post.

13
0 735
Question Rustam Ibragimov · Aug 5, 2016

Hello, guys.

I need to copy the text from one stream to another filestream and save it. I am using  

do fileStream.CopyFromAndSave(rtn.Code)

However, if "rtn" stream contains Russian characters I get something like "???". Is there any way to convert stream to Unicode?  Something like $zc(str, "O", "UTF8") for streams.

3
0 493
Question James Fitzpatrick · Sep 28, 2016

Hi all,

This is a real long shot, but does anyone have experience integrating MS wsHttpBinding with a Cache application?

Link 

I ask because my project had some initial design discussions for new web service communication and this specification was mentioned. 

Thanks.

1
0 376
Question Rustam Ibragimov · Sep 9, 2016

Hello, guys. 

I found one interesting moment in Cache Object Script. It doesn't have(or at least I didn't find) trimming function. By trimming I mean if a string has some whitespaces/tabs/carriage returns from very beginning or/and from very right, this function removes them. 

  I have found several workaround ways. 

1. Using Cache Basic

ClassMethod TrimCacheBasic(str As 

2. Using SQL

ClassMethod TrimSQL(str As %String) As %String
{
	set tStatement = ##class(%SQL.Statement).%New()
	set tSC = tStatement.%Prepare("SELECT TRIM(?)")
	set rset = tStatement.%Execute(str)
	do rset.%Next()
	return rset.%GetData(1)
}
6
0 2144
Question Scott Beeson · Jun 21, 2016

I'm following the tutorial here.  When I try to call the default Test() method I get the following error:

An error occurred with the CSP application and has been logged to system error log (^ERRORS)

I found this document which says I need to make the "Web Application" accessible by running a couple commands.  I'm not even sure I created a Web Application.  Regardless, I tried a few variants but still get the same error.

Here is the URL for the Service Catalog: /csp/healthshare/mhclib/Custom.MHC.Scott.ServiceTest.

5
0 3334
Article John Hotalen · Sep 29, 2016 1m read

Checking if Directory or File Exists:

Outlined below is an example of how to check if a directory exists:

Set directoryName="c:\temp\nosuchdir"

/* Check for existence of a directory - Return Value:  0 - directory does not exist;  1 - directory does exist  */

Set directoryExists=##class(%File).DirectoryExists(directoryName)

If ('directoryExists)  // do the processing for when a directory does not exist


Outlined below is an example of how to check if a file exists:

Set fileName="a_test_filename.txt"

/* Check for existence of a file- Return Value:  0 - filename does not exist;  1 - filename does exist  */

Set fileExists=##class(%File).Exists(fileName)

If ('fileExists)  // do the processing for when a filename does not exist
1
0 3393
Question Ponnumani Gurusamy · Sep 22, 2016
Hi ,
 1.  I will ready to write  a cache Developer Certification Level1. 
 2.  How to prepare this exam and any mock test available.
 3.  Where place to I will write exam . (Online as I will write a exam in my home place ).
 4. Will i Complete and pass 1st level , you will provide certificate.
1
0 705
Question Scott Beeson · Sep 27, 2016

I need to do an UPDATE via SQL and I would like the statement to return the `ID` column of each row that is updated.  MS SQL has an "OUTPUT" statement, but I don't see anything similar in Cache.  Is there a way to do this?

4
0 906
Article Mike Kadow · Sep 24, 2016 1m read

NewBie's Corner Session 29 Documentation on the Caché/MUMPS Global Structure

Welcome to NewBie's Corner, a weekly or biweekly post covering basic Caché Material.

This post contains several links to very good documentation of the Caché Globals Structure.

Like I said, "Perhaps the most difficult concept in Caché/MUMPS is its Global Structure."

universalNoSQL.pdf - http://mgateway.com/docs/universalNoSQL.pdf

by Rob Tweed and George James

Extreme Database programming with MUMPS Globals

http://gradvs1.mgateway.com/download/extreme1.pdf

6
0 566
Article Steve Wilson · Sep 23, 2016 2m read

 Windows 7 and some other Microsoft Operating Systems can shutdown too fast for large applications, such as a Cache instance with a large amount of data and changes, to close gracefully. This results in the instance being forced down by the OS and so causing problems on the next start up.

To solve this we can change the OS shutdown timeout values to give Cache more time to close gracefully. We do this by editing some settings in the Registry.

1.Click Start (on Win 7) and type “regedit” and make sure you run registry editor as administrator.

 

2.

9
0 2396
Article Eduard Lebedyuk · Sep 26, 2016 2m read

We're developing Ensemble PoC and one day our frontend developer (who doesn't have Ensemble production running) said that Populate just doesn't cut it and he needs to see the real data. He needed only one object, but the problem was - it's a big object. Still, I checked ids of everything related and wrote this command (parts omitted, but you get the idea):

w
$SYSTEM.OBJ.Export("project.model.contract.ContractD(6456).gbl,project.model.coA7F9.ObjectAddressD(6741).gbl,project.model.meter.DeviceD(23398).gbl,project.model.StatusHistoryD(7977).gbl,project.model.StatusHistoryD(48006).gbl,project.model.StatusHistoryD(83906).gbl","C:\Users\eduard\Desktop\export.xml")
1
0 820
Question Ponnumani Gurusamy · Sep 23, 2016

I tried to get a image from user . But It did not run. So please solve this problem

Class Quadramed.Chennai Extends %Persistent
{
Property Image As %Stream.FileBinary(LOCATION = "C:/Images");
Method imagefile()
{
obj = ##class(Sam.binary).%New()
"enter your name",img
obj.Image.Write(img)
status = obj.%Save()
}
 

5
0 1197
Article Mike Kadow · May 12, 2016 2m read

NewBie's Corner Session 1 Installing Caché

Welcome to NewBie's Corner, a weekly or biweekly post covering basic Caché Material.

Session 1 - InterSystems Inc. allows you to download a single copy of Caché to your personal computer at no cost. This is available from www.InterSystems.com.  It is at this link: https://download.InterSystems.com. You will first need to register yourself with InterSystems. Follow the instructions on how to download the install file. Choose the full version of Caché, not the Client Components.

11
0 1350
Article Mike Kadow · Jun 23, 2016 2m read

NewBie's Corner Session: 9 Documentation and books

Welcome to NewBie's Corner, a weekly or biweekly post covering basic Caché Material.

To access your documentation:

Assuming you have installed Caché, (see NewBie's Corner, Session:1),

Click on the InterSystems cube in the Windows system tray, then choose Documentation.

4
0 627
Question Rich Taylor · Aug 18, 2016

I have setup an async reporting mirror member with Read only access.  My problem is that if I try to do any sql reporting against that data I am getting errors.  I am sure that this is because the DB is read only, but I had assumed that setting up a reporting mirror would handle this.

I there a setting or mapping  I am missing?

7
0 849
Question Ponnumani Gurusamy · Sep 21, 2016

How to get a input in array collection with class properties.

Class collect.arraylist Extends %Persistent
{
Property DOB As %Collection.ArrayOfDT;
ClassMethod valu()
{
list = ##class(collect.arraylist).%New()
""your DOB:", DOB1
do list.arraylist.SetAt("DOB1",0)
}
 

3
0 1229
Question Ponnumani Gurusamy · Sep 21, 2016

I get a input from user.How to I retrieve the data from these input. I enter the program but its occurred Some error .So give an idea of how to retrieve the data from properties.

ClassMethod Getvalue()
{
Details = ##class(Sample.Employeedetails).%New()
"Enter Your Name:" , Name1
Details.Name = Name1
"Enter Your Address :", Address1
Details.Address = Address1
"Enter your Phone Number:",Phonenumber1
Details.Phonenumber = Phonenumber1
"Enter your Blood Group:", Bloodgroup1
Details.Bloodgroup = Bloodgroup1
"Enter Your Desination:",Desiation1
Details.

7
0 398