#Caché

30 Followers · 4.6K Posts

  

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

Documentation.

Article Kurro Lopez · Jan 24, 2018 3m read

Sometimes, we need to copy part of the properties of an object into a different one. 
The simplest thing would be to do the following:

Set obj1.FirstName = obj2.FirstName

Set obj1.SecondName = obj2.SecondName

What happens if the object contains a large number of properties? or we just want to extract an important group of data, and complement the information in another object?

Having the following classes:

Class Kurro.PersonalInfo Extends %Library.SerialObject
{
 /// Code of personal
 Property Code As %String;
 
 /// First name of personal
 Property FirstName As %String;
 
 /// Second name of personal
 Property SecondName As %String;
 
 /// Date of birthday of personal
 Property DateOfBirthday As %DateTime;
 
 /// Passport ID number
 Property PassportId As %String;
  
}



Class Kurro.NameInfo Extends %Library.SerialObject
{

 /// First name of personal
 Property FirstName As %String;
 
 /// Second name of personal
 Property SecondName As %String;
 
 /// Date of birthday of personal
 Property DateOfBirthday As %DateTime;

 /// Relationship
 Property Relationship As %String;
 
}

6
0 1893
Question Julie Marulappa · Apr 26, 2018

I am trying to create a list of id's which are of type integer. I have created a class like below and then I am trying to call the class from a BPL to first initialize the list. In the BPL, I have an assign action that is using set and a context variable setup to hold the list data. The property is using the class I have created, ##class(MSI.IN835.EOBList).%New(). I keep getting an error back saying the method does not exist. Why does it not like the %new method? I am new to cache object script, so if their is a better way to do this, I am open to that as well.

Class MSI.IN835.

9
0 2202
Question Георгий Самаров · Apr 27, 2018

Hi! I have a local project written on Cache and Atelier on my PC. I need to move it to notebook. Tried to export globals, classes, MAC-programms and csp with frontend stuff, but after I created my apps on notebook and imported my set, it just didn't work. I think it's because I have some settings on Management Portal, so how can I export portal settings and what I should export to have my working apps on another computer?

3
0 413
Article PILAR GUERRERO · Apr 25, 2018 4m read

Hi everyone!

I want to share four functions with you. I hope that you can use it at some time.

DNI: the initials of the type of national identity document, is composed of different series of numbers and letters. That proves the identity and personal data of the holder, as well as the Spanish nationality. Example: 94494452X

NIE:  The NIE or foreigner identity number is a code for foreigners in Spain.


In this page you can generate examples of DNI or NIE https://generadordni.es/

The first function calculates the letter of  a DNI number.

8
0 991
Question Antonio Garcia Martinez · Apr 26, 2018

Hi,

I have a service  that I need to receive notifications from when the service has started. Usually this service will be off, but when started a need a method to be called so I can email and be alerted. The only method I know I can use is " OnProcessInput" but this is when an input is received (new file, new message...) but I could not find any events to deal when the service starts...I tried "OnInit" but does not seems to work...any ideas?

Class xxxx Extends Ens.BusinessService
{
Method OnInit() As %Status
{
$$$LOGINFO("INIT")
}
Method OnProcessInput() As %Status
{
// do something here
}
}
3
0 443
Question Nezla · Apr 23, 2018

Hello,

I'm restating a new posted as its seems that the old was closed but still having problems.
as I mentioned in a previous post and with one of our clients, experiencing different crushing errors when running Crystal Reports and sometimes crystals running but not generating data.etc  and we are temporarily fixing them by opening the related classes in Studio and recompiling them and as i mentioned compiling them with $System.OBJ.

2
0 429
Question Yuval Golan · Apr 23, 2018

Hi,

The following sql statement is working through the SMP but couldn't make it work through the code.

The table is a linked table to oracle db.

Tried to change the date property in the linked table class from %Date to %String and also tried using %SQL.Statement and %Library.ResultSet

this work through SMP:

INSERT INTO PACKAGE.SOME_TABLE_NAME

(EFFECTIVE_START_DATE,MORE,DATA,HERE)

VALUES (to_date ('2018-04-01','yyyy-mm-dd'),123,456,789)

In the code i'm using '?' in the statement for the parameters.

14
0 538
Question Nael Nasereldeen · Apr 24, 2018

Hi,
Trying to work with REST protocol, using IIS 8, both client and server are Cache servers,
I have the following problem- 
When I send a PUT command, I get the following error:
<HTML><HEAD><TITLE>Length Required</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<BODY><h2>Length Required</h2>
<hr><p>HTTP Error 411. The request must be chunked or have a content length.</p>
</BODY></HTML>

Get , Post , Delete - work OK.
This problem does not happen if I use Apache, so it's a IIS problem , not a Cache problem.

2
0 1017
Question Gary Marston · Apr 20, 2018

Hi,

   I have a ZEN application that displays PDF files in an 'iframe', embedded on a ZEN popup dialog. embedded in a ZEN page running on IE 11 with its document mode set to 5, which is enough to make most reasonable people give up and start selling hot dogs in the park.

  I can display the PDF all day long without issue but when the "window.print()' command is issued all I get for the PDF is an empty area on the printed page when a single page of the PDF should be displayed. The PDF arrives as a normal PDF file and is NOT base64 encoded. I have had limited success using the PDF.

4
0 1140
Question Nezla · Apr 15, 2018

Hi Guys,

We experiencing a strange problem with one of the clients on Cache 2008, for time to time they can't run any of their Crystal reports and each time we had re-compile the classes used in the affected report to get it running, then it happens again for the same reports.

7
0 977
Question Roberto Cahanap · Apr 13, 2018

We are going to start using Git within Cache.

One question came up - if the branch that you checked out does not have the class or mac file, what is the correct thing to do?

Should we delete from Cache or should we just keep it?

I'm leaning more towards deleting it because Cache should reflect what is in your work folder in git. But other team members are saying to keep it.

16
0 721
Question Stephen Wilson · Apr 19, 2018

Does developing a RESTful API in Caché remove the requirement to use the InterSystems.Data.CacheClient.dll and generate proxy classes using the Caché Object Binding Wizard for .NET web development? If anyone has links to sample applications using .NET with Caché and REST Services, I would be grateful if you could share them.

4
0 639
Question Bharathsimha Reddy Jakka · Apr 18, 2018

How to convert SQL persistent classes to JSON output - I have tried 1 option but appears to be very lengthy process.

I have many other SQL storage's defined and have to expose them as well to JSON. Can anyone please suggest a better approach.

My column names usually match with my Json properties.

My User.TestClass is the class with GetJsonList() as my method to return /output JSON formatted data.

The Code tried and SQL storage structure are as follows -

Class User.TestClass Extends %RegisteredObject
{
ClassMethod GetJsonList() As %Status
{
Set SQL="SELECT ID, Column1, Column2, DataID FROM SQLUser.

3
0 1211
Question Casey Fieldmann · Apr 17, 2018

A client wants information extracted from their MUMPS database and transferred to a cache database, where do I begin and what are some best practices I should keep in mind? (I am fairly new to MUMPS and have been put on this project)

1
0 837
Question Jenna Makin · Apr 15, 2018

Hi-

I have the following objects

Class A

   Property P1 As B

   Property P2 As %String

   Property P3 As %String

Class B

   Property P1 As %String

Can I create an index in Class A based on P1.P1.  Basically I want an index of class A by property P1 in class B

I tried creating the following but got a compile error

Index I1 On P1.P1

Thanks

2
0 594
Question Kevin Furze · Apr 13, 2018

I use macros everyday, but its the first time I want to create a macro like this

I want to create a new macro whereby I can pass a variable amount of parameters

the macro (much simplified version) would be 

#define myMacro(%params)         $listBuild(any Number Of %params I pass in)

so I want to be able to call $$$myMacro(user,ID,vehicle)         ie 3 parameters would generate

$lb(user,ID,vehicle)

but equally I might want to call that same macro $$$myMacro(companyID)          ie 1 paramter and would generate

$lb(companyID)

so the question is, 

how can I create the macro without knowing how many parameters I'm passing in up front.

4
0 547
Question Mike Minor · Apr 6, 2018

I am tasked with using CACHE to insert data retrieved from a CACHE data base and insert it into an sql database. The columns in the sql table that I am trying to insert data into have names that contain underscores such as "ACCESSION_DATE" I found a utility in CACHE to connect to the sql data base and perform inserts. I have the data I need to insert. I need to pass the  data into the sql utility referencing the column names.

I tried using indirection to set the data into underscored variables, but that isn't allowed  in cache object script.

Anyone have suggestions as to how to do that?

8
0 1620
Question Eduard Lebedyuk · Apr 5, 2018

Hello, Community!

Here's an interesting task I found on the Internet.

Problem description

Write a method that would draw a box of a specified size.

The goal is to write the shortest method.

Here's a method signature (it can't be modified):

ClassMethod main(s As %Integer = 10)

And call sample:

>do ##class(ITPlanet.Task4).main(5)
#####
## ##
# # #
## ##
#####

>do ##class(ITPlanet.Task4).main(10)
##########
##      ##
# #    # #
#  #  #  #
#   ##   #
#   ##   #
#  #  #  #
# #    # #
##      ##
##########
 
>do ##class(ITPlanet.Task4).main(20)
####################
##                ##
# #              # #
#  #            #  #
#   #          #   #
#    #        #    #
#     #      #     #
#      #    #      #
#       #  #       #
#        ##        #
#        ##        #
#       #  #       #
#      #    #      #
#     #      #     #
#    #        #    #
#   #          #   #
#  #            #  #
# #              # #
##                ##
####################
15
0 758
Question Scott Roth · Apr 6, 2018

Is there a way to make the system users like _SYSTEM and ensadm bypass the Delegated sign-on and not cause it to fill up the Audit trail with "Programmer mode login failure"?? I figured I still had to leave password login enabled for the background users to run. How would I script if username = "_SYSTEM" then don't do the Delegated sign on?

Here is my ZAUTHENTICATE

s $zt="Error"
  s Status = 0
  i Password="" {
    s Status= $SYSTEM.Status.Error($$$InvalidUsernameOrPassword)
    g Error
  }
  i $$$WindowsLDAPServer {
    s AdminDN=$Get(^OSUMCLDAP("User"))
    s AdminPW=$Get(^OSUMCLDAP("Pass"))
  }
  //Connect to the LDAP server
  s LD=##Class(%SYS.LDAP).Init($$$LDAPServer)
  i LD=0 {
    s Status=##Class(%SYS.LDAP).GetLastError()
    s Status="Init error: "_Status_" - "_##Class(%SYS.LDAP).Err2String(Status) 
    g Error
  }
  //Authenticate the passed in user by using the Binds command 
  //s Domain="OSUMC.EDU"
  #; Begin Binding Process"
  s Status=##Class(%SYS.LDAP).SimpleBinds(LD,AdminDN,AdminPW)
  i Status'=$$$LDAPSUCCESS  {
    s Status = Status_", ldap_Simple_Bind(AdminDN) - "_##Class(%SYS.LDAP).Err2String(Status) 
    #;w !,Status
    g Error
  }
  i $$$WindowsLDAPServer {
    s Filter=$$$WindowsFilter_"="_Username
  }
  i $$$WindowsLDAPServer {
    s AttributeList=$$$WindowsAttributeList
  } 
  i $$$WindowsLDAPServer {
    s BaseDN=$$$WindowsBaseDN
  } 
  s SearchScope=$$$LDAPSCOPESUBTREE
  s Timeout=30
  s SizeLimit=1
  s Status=##Class(%SYS.LDAP).SearchExts(LD,BaseDN,SearchScope,Filter,AttributeList,0,"","",Timeout,"",.SearchResult)
  i Status'=$$$LDAPSUCCESS {
    i Status=$$$XLDAPFILTERERROR {
      s Status="1,User "_Username_" does not exist"
      w !,Status
    } else {
      s Status=Status_",ldap_Search_Ext - "_##Class(%SYS.LDAP).Err2String(Status)
    }
    g Error
  }
  s NumEntries=##Class(%SYS.LDAP).CountEntries(LD,SearchResult)
  i NumEntries=-1 {
    s Status=##Class(%SYS.LDAP).GetError(LD)
    s Status=Status_",ldap_Count_Entries - "_##Class(%SYS.LDAP).Err2String(Status)
    g Error
  }
  i NumEntries=0 {
    s Status="1,User "_Username_" does not exist"
    g Error
  }
  i NumEntries>1 {
    s Status="1,LDAP Filter is not unique"
    g Error
  }
  s CurrentEntry=##Class(%SYS.LDAP).FirstEntry(LD,SearchResult)
  i CurrentEntry=0 {
    s Status=##Class(%SYS.LDAP).GetError(LD) 
    s Status=Status_",ldap_FirstEntry - "_##Class(%SYS.LDAP).Err2String(Status)
    g Error
  }
  s DN=##Class(%SYS.LDAP).GetDN(LD,CurrentEntry) 
  i Password="" {
    s Status="1,ldap_Simple_Bind("_DN_") - password cannot be null"
    g Error
  }
  s Status=##Class(%SYS.LDAP).SimpleBinds(LD,DN,Password)
  i Status'=$$$LDAPSUCCESS {
    s Status=Status_",ldap_Simple_Bind("_DN_") - "_##Class(%SYS.LDAP).Err2String(Status)
    g Error
  }
  s Attribute=##Class(%SYS.LDAP).FirstAttribute(LD,CurrentEntry,.Ptr)
  while (Attribute'="") {
    s Values=##Class(%SYS.LDAP).GetValuesLen(LD,CurrentEntry,Attribute)
    #;Values:"_Values
    s Properties("Attributes",Attribute)=Values
    s Attribute=##Class(%SYS.LDAP).NextAttribute(LD,CurrentEntry,.Ptr)
  }
  s Properties("Username")=Username
  s Properties("FullName")=$li(Properties("Attributes","displayName"))
  k Properties("Attributes","displayName")
  s Properties("Comment")=$li(Properties("Attributes","department"))
  k Properties("Attributes","department")
  s Properties("EmailAddress")=$li(Properties("Attributes","mail"))
  k Properties("Attributes","mail")
  s GroupFilter="(&(objectClass=group)(member:1.2.840.113556.1.4.1941:="_DN_"))"
  s GroupAttributes=""
  s Status=##Class(%SYS.LDAP).SearchExts(LD,BaseDN,$$$LDAPSCOPESUBTREE,GroupFilter,GroupAttributes,0,"","",10,0,.GroupSearchResult)
  #;GroupSearch Status: "_Status
  i Status'=$$$LDAPSUCCESS {
    w !,"SearchExts error: "_Status_" - "_##Class(%SYS.LDAP).Err2String(Status)
    g Error
  }
  s GroupNumEntries=##Class(%SYS.LDAP).CountEntries(LD,GroupSearchResult)
  i GroupNumEntries=-1 {
    s Status=##Class(%SYS.LDAP).GetError(LD)
    s Status=##Class(%SYS.LDAP).Err2String(Status)
    g Error
  }
  w !
  i GroupNumEntries=0 {
    w !,"No nested groups for "_Username_" found"
    g Done
  }
  i GroupNumEntries>0 {
  }
  s GroupCurrentEntry=##Class(%SYS.LDAP).FirstEntry(LD,GroupSearchResult)
  i GroupCurrentEntry=0 {
    s Status=##Class(%SYS.LDAP).GetError(LD)
    w !,"FirstEntry error: "_Status_" - "_##Class(%SYS.LDAP).Err2String(Status)
    g Error
  }
  s Groups=""
  While (GroupCurrentEntry'=0) {
    s GroupDN=##Class(%SYS.LDAP).GetDN(LD,GroupCurrentEntry)
    i GroupDN="" {
      s Status=##Class(%SYS.LDAP).GetError(LD)
      w !,"GetDN Group error: "_Status_" - "_##Class(%SYS.LDAP).Err2String(Status)
      g Error
    }
    s CN=$p(GroupDN,",",1)
    s AD=$p(CN,"=",2)
    s AD=$zcvt(AD,"L") 
    s exists=''$d(^|"%SYS"|SYS("Security","RolesD",AD))
    i exists{
      s Properties("Roles") = AD
      #;w !,Properties("Roles")
    }
    s GroupCurrentEntry=##Class(%SYS.LDAP).NextEntry(LD,GroupCurrentEntry)
  }
Done
  i $d(SearchResult) d ##Class(%SYS.LDAP).MsgFree(SearchResult)
  i +$d(LD) d ##Class(%SYS.LDAP).UnBinds(LD)
  q $SYSTEM.Status.OK()
Error s $zt=""
  i $d(SearchResult) d ##Class(%SYS.LDAP).MsgFree(SearchResult)
  i +$d(LD) s Status=##class(%SYS.LDAP).UnBinds(LD)
  i $ze'=""{
    q $SYSTEM.Status.Error($$$CacheError,$ze)
  } else {  
    q $SYSTEM.Status.Error($$$GeneralError,"LDAP error: "_Status_" - "_##Class(%SYS.LDAP).Err2String(Status))
  }
3
0 467
Question Scott Roth · Apr 6, 2018

We have scripted a process where we can run EnableConfigItem from the cron in AIX so we can run multiple scripts at a time vs the scheduler in Ensemble that is single threaded. For the most part this works fine, until that service/operation has an error on it then it seems that everything else that is called after that instance halts.

Is there something that is stopping EnsConfigItem() from running once something has error'd?

Can something be forced like it does if we try to enable/disable in the gui and it times out?

this is the single command line we are calling

zn "$1"
w ##class(Ens.Director).

3
0 663