#Caché

1 Follower · 4.5K Posts

  

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

Documentation.

Question Tiago Ribeiro · Oct 18, 2018

Hello all...

Is there two matching patterns in Caché, is there a difference in use one or the other?
Example:

USER>set a = "(1234)"

Using $match.

USER>w $match(a,"\([0-9]{4}\)")

USER>1

Using literal match (sorry if not correctly term expression)

USER>W a?1"("4n1")"

USER>1

What is different from using one or the other?

The 'a?1"("4n1")"' does this pattern exist only Caché.
Exists performance improvement with use pattern Caché?

2
0 638
Question Sean Connelly · Oct 17, 2018

I can directly order over a MultiDimensional property, e.g.

set key=$order(obj.prop(key))

However I have a generic method that has to use the $property method, if I know the keys then I can just fetch a value with...

set value=$property(obj,"prop","key")

But if I don't know the keys then I am not aware of a solution to do this, e.g.

set key=$order($property(obj,"prop",key))

will not work.

There must be an internal solution as a zw command on obj is able to list all of the keys. I'm wondering if there is a $zu function or other trick that can do this. Any ideas?

Thanks,
Sean.

6
0 586
Article Daniel Kutac · Apr 13, 2017 3m read

Recently, a partner company started to develop an Angular client for their Cache application. Together, we decided to leverage the power of Caché dynamic objects to exchange JSON encoded data between client and server parts. However, we realized that currently there is a gap in Cache JSON implementation that prevents simple use of traditional registered and persistent classes to exposed their data with the same ease as with XML. I wrote a small JSON adapter, that does the job and bridgers the gap. It's purpose is simple expose data described by a regular Cache class in a one-to-one fashion to

7
1 2234
Question Stephen Wilson · Oct 8, 2018

I think I already know the answer to this but I thought I'd ask anyway. So the Node.js adapter allows you to perform operations directly on Globals. Does the InterSystems.Data.CacheClient.dll or InterSystems.CacheExtreme.dll provide a mechanism to access Gobals directly or are you accessing globals via Caché ObjectScript classes?

5
0 631
Article Gevorg Arutiunian · Oct 18, 2018 1m read

This code snippet uses %ZEN.Auxiliary.jsonSQLProvider. The namespace and string of SQL can be edited for different situations. The class method "test" runs the code:


Class eduardlebedyuk.passQuestionParams
{
	classmethod test(pValue = 50) {
		s ns = $Namespace
	    zn "samples"
	    s tSQL = "SELECT ID, Name FROM Sample.Person WHERE Id > ?"
	    s tPR = ##class(%ZEN.Auxiliary.jsonSQLProvider).%New()
	    s tPR.sql = tSQL
	    s tPR.%Format = "tw"
	    s tPR.maxRows = 100
    s tParam = ##class(%ZEN.Auxiliary.parameter).%New()
    s tParam.value = pValue
    d tPR.parameters.SetAt(tParam,1)
  
    d tPR.%DrawJSON() 
    //d ##class(%ZEN.Auxiliary.jsonSQLProvider).%WriteJSONFromSQL(,,,,,tPR)  //same thing
    zn ns
}

}

(Originally posted to Intersystems CODE by @Eduard Lebedyuk, 5/13/15)

Here's a link to the code on GitHub

0
0 318
Question Peter Kopp · Oct 17, 2018

I have a ZEN page with nine tablepanes. Each tablepane queries a table in the same SQLServer db. I have a single SQLGateWay(odbc) to this SQLServer db. I need to get better performance when I query all nine table at the same time. Would my performance improve if I had nine SQLGateWays(nine odbc configurations/connections), one for each query? I would appreciate any and all suggestions for getting the very best performance when using SQLGateWays. Thank you.

1
0 354
Question David Foard · Oct 17, 2018

I have created a view to stage some data in a different format and then want to reference that view in a SQL query from a table that filters the data from the view using a property of the table. 

Example:

select
   MsgId,
   FileName,
   (select
      ReportName
     from
      custom_view
     where
       MsgId = ReportId
    ) as ReportName
from
   main_table

Is this even possible? When I try this, I get an error table not found for the view?

David

1
0 323
Question William Proctor · Sep 27, 2016

All responses are appreciated.  I am new to both scripting and CACHE so please bear with me.  I am setting up a nightly backup script for freezing cache then backing it up and then thawing it back out.  Currently when I enter the freeze command I am getting a response of access denied even though my id has %all access.  I've tried passing the userid/password as a parameter in the externalfreeze command and passing it from a file.  I've used my id and lastly I used the _system id in the file.  What ID should I use for this or am I passing it wrong?

17
0 1226
Question Danillo Aquino · Oct 15, 2018

I would like to know how to choose the "Development" installation type in silent mode.

When performing a normal installation:

Please review the installation options:
------------------------------------------------------------------
Instance name: CACHE
Destination directory: /cache
Cache version to install: 2015.2.1.705.0.17420
Installation type: Development

When I perform a silent install:

3
0 580
Question Bill Asby · May 20, 2016

Hi,

I ran the Cache ODBC Driver installer as Administrator on my Windows 7 PC this morning. It completed successfully with o indication of any issues. When I check installed programs and features via Win 7 Control Panel, I see it listed as Intersystems ODBC Driver 1.00.000.

However, when I try to configure the driver via Control Panel - Administrative Tools - Data Sources (ODBC), I cannot find it. The only driver listed under the Drivers Tab is SQL Server.

I am not sure how to proceed.

I appreciate any suggestions.

Thanks,

Bill

5
0 1679
Question Anne Kantola · Oct 15, 2018

In our language we have scandic letters like ä (a with two dots on it).

In Angular we use login like this:

let headers = new Headers();

password = Base64.fromBase64(password);

headers.append('Authorization', 'Basic ' + Base64.encode(username + ':' + password));

let options = new RequestOptions({ headers: headers, withCredentials: true });

return this._http.get(_param.baseUrl + this._loginUrl, options)

.map((res: Response) => {

It works, but not with these letters.

In other cases we convert data on server side like

set:tValue'="" tValue=$ZCONVERT(tValue,"I","UTF8")
 

3
0 395
Question Sabarinathan M · Mar 13, 2018

Hi All,

I need some help with sending PDF files to printer using cache instead of using third party tools(Adobe, foxit reader, etc..).
Sometime i getting access issue with the exe files.

Can able to send text data to printer using below code.

Set Dev="|PRN|PrinterName"
OPEN Dev:(/DATATYPE="TEXT"):80
USE Dev Write "Test printing",!
CLOSE Dev


Any suggestions on sending PDF to printer?

3
0 976
Question Vivek Ranjan · Sep 28, 2018

Method1(){

Set OID1=##class(Table).%OpenId(100)

// do Kill OID

}

&SQL(Update Table Set  Column=88)

Method2(){

Set OID2=##class(Table).%OpenId(100)

// Or do %Reload()

Set OID.Column=99

Do OID.%Save()

}

// Column 1 still holds value as 1

For getting the updated value I should do Kill OID in Method1

4
0 672
Article Alexey Maslov · Nov 23, 2017 12m read

It's well-known that namespace global mapping helps us to write code independent on database storage details (Caché instance name, directory path). But sometimes we can face problems accessing an unsubscripted global which has subscript level mapping (SLM) defined. Most of such cases are evident and associated with administrative tasks that should be done on database level, but some of them can confuse even an experienced developer. Just to start:

  • We can't export such a global using Caché Block format (a.k.a. GOF).
  • We can't kill such a global.

Maybe you can continue this list.

8
0 1459
Question Udo Guengerich · Sep 26, 2018

Upgrade of custom application

Dear community,

we are a company located in central Germany working with Intersystems Caché since 2003 (Jesus, that's actually a long time in IT).

As we struggle to keep pace with outside development we still operate on Caché 2013.1 surprise

We are, of course, aware that we need to upgrade Caché and therefor plan an upgrade to 2017.2.

Now my question to you bold ObjectScript warriors:

4
0 471
Question Ravi Nagpal · Oct 10, 2018

Hi, 

Can we create a new class in the studio using any command rather then using the Menu Item Option from Menu Bar in Studio . 

Requirement : Create/Draft a new class and able to extends the other classes using  a command in Cache Class .

In other words , I want to Dig in the Menu Item class from which Menu bar is created in studio and option are provided  Like New..., Open..., etc 

Thanks, 

Ravi 

1
0 296
Question Laura Cavanaugh · Oct 3, 2018

I'm running this code in our application, and in the terminal:

>set query="SELECT * FROM PMG_Data_Private.RemitInstance  WHERE  (VoucherNumber %INLIST ? SIZE ((10)))"

>set tRS = ##class(%ResultSet).%New("%DynamicQuery:SQL")

>set ok=tRS.Prepare(query)

>d $system.Status.DisplayError(ok)
 
ERROR #5540: SQLCODE: -76 Message: Cardinality mismatch between the SELECT-list and INTO-list
SQLTEXT: SELECT * FROM PMG_Data_Private.RemitInstance  WHERE  (VoucherNumber %INLIST ? SIZE ((10)))

5
0 1764
Question sansa stark · Oct 9, 2018

Hi all,By using LDAP cache method ##Class(%SYS.LDAP).GetValuesLen(LD,CurrentEntry,Attribute) we get the list of attributes but in "ObjectSid" attribute have the SID in binary format(objectSid^U¤:c@ãºþÕLCP]). how to convert to the readable format from the binary format in cache side. Please help us to proceed further

3
0 439
Article Gevorg Arutiunian · Oct 8, 2018 2m read

This code snippet provides a ZEN page that downloads a stream from its database directly:


/// We assume that you have stored your data within this schema:
/// MyApp.Model.Storage: Filename,FileSize,Content,ContentType
Class zen.downloadStream Extends (%ZEN.Component.page,%CSP.StreamServer)
{
/// Wrapper to get the id of the download, we assume that the id is passed to this zen page
/// as a URI parameter, i.e.: MyApp.Downloads.cls?OID=1234
ClassMethod GetId()
{
    Quit $Get(%request.Data("OID",1))
}
 
/// Set the appropriate header for the file.
ClassMethod OnPreHTTP() As %Boolean
{
    Set tId = ..GetId()
 
    If ##Class(MyApp.Model.Storage).%ExistsId(tId) {
        Set tStream = ##Class(MyApp.Model.Storage).%OpenId(tId)
        // You could "guess" the content type by its file extension
        // or you can store it (before) in the database separately (like in this example).
        // Set Extension = $Piece(tStream.Filename,".",$Length(tStream.Filename,"."))
        // Set ContentType = ..FileClassify(Extension)
 
        Set %response.ContentType = tStream.ContentType
        Do %response.SetHeader("content-disposition","attachment; filename="_tStream.Filename)
        Do %response.SetHeader("Content-Length",tStream.FileSize)
    }
    Else {
        Set %response.Status="404 File Not Found"
        Quit 0
    }
    Quit $$$OK
}
 
ClassMethod OnPage() As %Status
{
    Set Download = ##Class(MyApp.Model.Storage).%OpenId(..GetId())
    Do Download.Content.OutputToDevice()
    Quit $$$OK
}

}

Link to code on GitHub

1
2 645
Question Tuan Minh Do · Oct 4, 2018

Hello,

I am a beginner with Object Script and I hope anyone can help me solving my questions.

1. Is there a way to time a loop in Object Script? 

2. My code leads to the following error, even though it executes the method.

Is there a way to ignore this specific error, so that I can repeat my code in a time loop over and over again without stopping? 

3
1 1033
Question Jagadeesha Krishnamurthy · Oct 3, 2018

Hi 

Anyone worked on "ccontrol  list " command execution through Cache Object Scripting.

I executed through  bat file passing this ../bin ccontrol  list  . Icould not get the results through COS  but executed in command prompt 

it pops up with notepad and list down Cache instances.

Need help here to address the same stuff through cache object scripting.

3
0 843