#Caché

30 Followers · 4.5K Posts

  

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

Documentation.

Question Sankar Manogaran · Dec 17, 2018

Hi,

We are using Cache 5.0,  we use Cache telnet and Other emulator (using telnet connection) to launch the applications.

Is there a way to identify the  type of device is used?.  Based on the emulator  I can few custom changes to be applied.

Thanks and Regards,

Sankar

1
1 304
Question Eduard Lebedyuk · Dec 16, 2018

I have a simple callout library:

#define ZF_DLL
#include 
#include 
#undef ERROR

int GetRandom(double* random) {
   // Py_Initialize();
   // Py_Finalize();
   *random = 1.0;
   return ZF_SUCCESS;
}

int main(int argc, char **argv)
{
   printf("Random: ");
   double random=0;
   GetRandom(&random);
   printf("%lf", random);
   return 0;
}

ZFBEGIN
    ZFENTRY("GetRandom","D",GetRandom)
ZFEND

I compile this code as a shared library and it works fine with:

set path = "library.dll"
write $ZF(-3, path, "GetRandom")

It also compiles and works as an executable.

4
0 615
Question Robert Osborne · Dec 13, 2018

Hello All,

Hoping someone can help with this odd error.

A vbscript file is being used to perform an update to cache.

The file has worked without an issue for well over a year.

Recently, the update has begun to throw an error.

(class references modified to remove client data)

UPDATE CACHE.UCI.Reg.Pat (Column1) VALUES ('USERNAME') WHERE ID = '2190284'

C:\Web\Config\SchedTasks\script1.VBS(73, 6)

Microsoft OLE DB Provider for ODBC Drivers: [Cache ODBC][State : S1000][Native Code 105]

[c:\Windows\SysWOW64\cscript.exe]

[SQLCODE: <-105>:<Field validation failed in UPDATE>]

[Location: <ServerLoop>]

3
0 679
Question Goran Stefanovic · Dec 12, 2018

A very simple SQL

SELECT field1 F1, count(field2) CntF2
FROM GCT.PA_Data
where field1 is not null
group by field1

gives an error back:

 [SQLCODE: <-461>:<Communication link failure>]

  [%msg: <Connection 'TRAKCARELIVE': Execute: SQLState: (HY000) NativeError: [10053] Message: [Cache ODBC][State : HY000][Native Code 10053] [c:\intersystems\ensemble\bin\cache.exe] Software caused connection abort> ]

It does work in another (test) environment, but not on live. Any idea why?

6
0 653
Question Jordi Gomez · Dec 10, 2018

Dear all,

In our application made in Caché object script, when we deploy some classes modified we have the option of calling "Purge queries" feature of Caché.

We only were doing this call when a %Persistent class definition (table) was modified, as we assume that no other changes affect the cached queries and we don't  want to purge them by default, as the first run of a query becomes slow.

We had a case where no table definition was changed but a purge queries was the solution.

Do you know if any other change could affect the cached queries and a purge queries is necessary? 

Regards,

3
0 318
Question Jimmy Ng · Nov 14, 2018

Hi. I have the following tables

User.Order [Parent][Primary Key : Year , Month, OrderNo]

 > User.OrderDetails [Child] [Primary Key : {%%PARENT}("ITM")(Running Number)]

 > User.OrderDetails2[Child] [Primary Key : {%%PARENT}("ITM2")(Running Number)]

  My question is there any problem if I use a composite key in User.Order?  I am using the composite key is because I have a lot of records each month(millions) and sometimes I will need to clear the records for a specific month for reloading, with those primary key removing the data would be easier (possibility faster too).

6
0 1867
Question John Kumpf · Dec 6, 2018

Hi guys,

I'm running a method on an instance of Cache 2010, which, when compiled, has $$$OK in it's .int code.  This line throws an error, telling me that "the OK macro isn't recognized". 

Some things I've tried;

- I looked it %occStatus, and the macro definition of OK is there.

- I changed $$$OK to 1 by hand in the .int code.  It compiled successfully, but each time I recompile the original class, it's going to put that $$$OK back

- I tried Include %occStatus at the top of the class.  The .int code was unchanged when I did this (is my syntax on that wrong?)

4
0 567
Article Sean Connelly · Nov 19, 2018 2m read

Here's a fun test to see how well you know ObjectScript.

What will each of the following statements output?

write 5 * 10 + 1

write 1 + 5 * 10

write 1 + 0 / 10

write 0 && 0 = 0

write 0 = 0 && 0

write 1 && 1 = 1

write 1 = 1 && 1

write 2 && 2 = 2

write 2 = 2 && 2

write "1 APPLE" + "2 BANANAS"

write "-1" + "1-2"

write +"+-+-+-5"

write "1D7P"-1

write "1E6F"-1

write 0 = "FOO"

write 0 = +"FOO"

write 0 = ''"FOO"

write "10X" - " 5" - "5"

write "10-5"

write +"10-5"

write @"10-5"

write 5_"1"-1

write "5"-1_"1"

write 10 + 10 > 21 + 1

13
2 1226
Question Gunwant Kapade · Dec 4, 2018

This is the class which I want to test.

Class GSK.MyTestUnit Extends %RegisteredObject {

ClassMethod Add(num1 As %Integer, num2 As %Integer) { s res=num1+num2 q res } }

This is my testing class.

Class GSK.TestingClass Extends %UnitTest.TestCase {

Method test() { Do $$$AssertEquals(##class(GSK.MyTestUnit).Add(3,8),41, "Test Add(2,2)=4 passed ") do $$$AssertNotEquals(##class(GSK.MyTestUnit).Add(3,8),11,"pass/fail") }

}

The test cases are passed even though they should fail.

s ^UnitTestRoot="C:\TestSuite1" d ##class(%UnitTest.Manager).RunTest("Test2")

1
1 366
Question David Foard · Dec 3, 2018

I am trying to use %INLIST in  SQL query using a cursor and the query fails to return results. It appears that the variable I use against %INLIST returns an empty string. All the examples I have seen use result sets and build the query as a string. Is it possible to use %INLIST in a cursor-based query? Below is a a snippet of the code I am using:

Property mylist as %String (MAXLEN="") [InitialExpression = "route1, route2, route3"];

set routeList = $LISTBUILD(mylist)

&sql(DECLARE MyReport CURSOR FOR

SELECT

      ProcessStartDate,

      ProcessCompleteDate,

      ProcessName,

     RouteName

FROM

3
0 752
Article Dmitry Maslennikov · Nov 5, 2018 13m read

I bet that not everyone familiar with InterSystems Caché knows about Studio extensions for working with the source code. You can actually use the Studio to create your own type of source code, compile it into interpretable (INT) and object code, and sometimes even add code completion support. That is, theoretically, you can make the Studio support any programming language that will be executed by the DBMS just as well as Caché ObjectScript. In this article, I will give you a simple example of writing programs in Caché Studio using a language that resembles JavaScript. If you are interested, please read along.

6
6 1319
Question Eduard Lebedyuk · Dec 2, 2018

I'm using this code to read a file, line by line.
Most lines are shorter than 32767 symbols, but some are longer. No line is longer than $$$MaxStringLength and long strings are enabled.
Is there a param to Open/Read command I can pass to increase Read limit?
My code:

set filename = pFile
open filename:("R")
for  {
    use filename read x
    quit:$ZEOF=-1
    set ^dbg($i(^dbg)) = $lb($e(x,1,10), $e(x,*-10,*), $l(x))
}
close filename

I've checked reclen parameter but it did not seem to help
 

3
0 345
Question Anthony Harrison · Nov 9, 2018

We are trying to get a custom header that I have added to a request to Cache, and I have seen the following in another post, however it doesn't work for us:

You can do it as in any CSP page/class. With %request, which is object of class %CSP.Request

And headers available in property CgiEnvs, where every http header appear with a prefix HTTP_

So, you may try this code.

set ipCountry=%request.GetCgiEnv("HTTP_CF_IPCOUNTRY")

I have verified in Charles (a Mac equivalent to the Windows traffic sniffer 'Fiddler' program) that my client sent the following headers in the request to Cache:

4
0 1509
Question Jiri Svoboda · Nov 9, 2018

Hi all,

I have an incoming JSON message with a string field exceeding in length the 'caché long-string limit' of 3641144 characters.

Using {}.%FromJSON(instream) I am able to create %DynamicObject properly. However, I am unable to access the long property, as in every assignment, I get the <MAXSTRING> error.

Is there any way for me to obtain contents of the 'too long' string field as a stream?

Thanks

Jiri

3
0 12591
Question Andrew Hubbard · Nov 19, 2018

When using the JSON_OBJECT() function in Caché SQL on a %String property that contains JSON syntax, it converts the %String into a JSON object instead of escaping it as a string literal. How can I prevent this? (without ridiculous hacks like "add a space to the beginning of the value" as we don't always know which properties will contain these values and I certainly don't want to have to check for nulls and add/remove a space every single place this value is used in the application)

I don't want these strings automatically marshalled into JSON objects.

For example:

12
0 1421
Question Rui Figueiredo · Nov 25, 2018

Hi,

I'm having the following error when returning a large dataset from a REST API.

"errors":[ {
            "code":5002,
            "domain":"%ObjectErrors",
            "error":"ERROR #5002: Cache error: <STORE>%0NmGk1+5^xxxxxx",
            "id":"CacheError",
            "params":["<STORE>%0NmGk1+5^xxxxxxxxxxxxxxxxxxxx"
            ]
        }
    ],
    "summary":"ERROR #5002: Cache error: <STORE>%0NmGk1+5^xxxxxxxxxxx"

My understanding is that this error is related to the amount of memory available. 

1
0 5050
Question Jack Mears · Nov 26, 2018

As part of a BPL I am building I need to foreach over a some repeating elements and look for a certain value, if said value is present I need to forward the message to another operation. 

I can't seem to get the if statement inside the foreach loop to work and I think I am doing something wrong?

The error message I am getting:

ERROR <Ens>ErrException: <UNDEFINED>zS2+2^GWH.Messages.Eobs.AKISegmentCheck.Thread1.1 *k1 -- logged as '-' number - @' Set k1=request.GetNextIndex("PIDgrpgrp("_(1)_").ORCgrp()",k1,.tSCTrans)'

Can anyone explain that error to me?

Cheers

3
0 961
Article Eduard Lebedyuk · Mar 1, 2018 6m read

Everybody has a testing environment.

Some people are lucky enough to have a totally separate environment to run production in.

-- Unknown

.

In this series of articles, I'd like to present and discuss several possible approaches toward software development with InterSystems technologies and GitLab. I will cover such topics as:

  • Git 101
  • Git flow (development process)
  • GitLab installation
  • GitLab WorkFlow
  • GitLab CI/CD
  • CI/CD with containers

This first part deals with the cornerstone of modern software development - Git version control system and various Git flows.

1
4 4970
Edit
Article Andrey Rechitskiy · Nov 22, 2018 13m read

As you know, Caché can be used as a relational DBMS working with JDBC/ODBC drivers and supporting the execution of arbitrary SQL queries and SQL procedure calls. 

We also know that Caché stores all the data in multi-dimensional sparse arrays called globals. It allows the developer not to use the standard CachéSQL engine in case a particular SQL procedure is underperforming, but instead rewrite its execution code in the Caché ObjectScript (COS) language intended for server-side business logic. This approach may help implement the optimal SQL procedure execution algorithm by using better-optimized NoSQL data structures (globals).

However, the standard class library in Caché has one limitation: for SQL procedures where data selection is controlled by custom COS code, you need to define the set of returned fields at the compilation stage - i.e. it is impossible to dynamically define metadata for an SQL procedure working with NoSQL structures. This article is about how to get around that limitation.

0
0 0
Question Fiona Griffiths · Nov 22, 2018

Hi

Is this a bug?  We came across it on an older version of Cache but I've also just tried it in version "Cache for Windows (x86-64) 2017.2.2 (Build 865U)" and got the same result.

Create a Class like so:

2
0 642