%OpenId Query

 

I am new to cache programming language . I am facing below issue . please assist.

 

Question: One persistent class ID column is a combination of its properties (Roll No and Marks) [ Exact: RollNo||Marks]. When i am running the query from Management portal it is displaying data in the same format and data is there. But in the code if i am making below statement, i am getting null value.

Set ExistsID=##Class(User.School).%ExistsId(RollNo_"||"_Marks)

set ID=##Class(User.School).%OpenId(RollNo_"||"_Marks)

 

ExistsID showing 1, but ID is always displaying as Null but data is there in class with that ID. Why?? If ID is passed as string will OpenId didn't work??

 

I am running with roll no:2 and Marks:11 [2||11}. In management portal it is displaying the same but in when i am trying to openid  ID is coming as Null every time. Why ??

  • 0
  • 0
  • 70
  • 5
  • 3

Answers

Try doing %BuildIndices() on the table then try doing %OpenId().

I tried to %Buildindices but it failed. Display Error method shows [Method not implemented].

##class(User.School).RollNoMarksExists(RollNo, Marks)

##class(User.School).RollNoMarksOpen(RollNo, Marks, , .sc)

I tried this above method but it is showing the below error.

Error #5002: Cache Error : <COMMAND>%Open+18^Library.Persistent.1

What does this mean??

use instead.

set ID=##Class(User.School).%OpenId(RollNo_"||"_Marks,,.sc)

do $system.OBJ.DisplayError(sc)

now you should see the reason why  ID=""

docs: https://cedocs.intersystems.com/latest/csp/documatic/%25CSP.Documatic.cls?PAGE=CLASS&LIBRARY=SAMPLES&CLASSNAME=%25Library.Persistent#%OpenId

##class(User.School).RollNoMarksExists(RollNo, Marks)

##class(User.School).RollNoMarksOpen(RollNo, Marks, , .sc)

I tried this above method but it is showing the below error.

Error #5002: Cache Error : <COMMAND>%Open+18^Library.Persistent.1

What does this mean??

When you have || in Id, it usually means, that you have additional Index by two or more fields, and marked as IdKey. Something like this.

Property RollNo As %String;

Property Marks As %String;

Index RollNoMarks On (RollNo, Marks) [ IdKey, Unique ];

Here we have some two properties, to store both values separately, but we used both of their values as IdKey.

Now it is possible to check of existing an object by ##class(User.School).%ExistsId(RollNo_"||"_Marks), or open id by  ##class(User.School).%OpenId(RollNo_"||"_Marks)

But in additional to this system methods, we now have some new ones which construct with index name and "Exists", "Open" and so on. But call will be a bit different. You should pass all values separately in this way.

##class(User.School).RollNoMarksExists(RollNo, Marks)

##class(User.School).RollNoMarksOpen(RollNo, Marks, , .sc)

You can try any of these ways, and you should remember about Status variable, which may help you to understand what's happening.

do $system.OBJ.DisplayError(sc)

will decode status

I tried to %Buildindices but it failed. Display Error method shows [Method not implemented].

##class(User.School).RollNoMarksExists(RollNo, Marks)

##class(User.School).RollNoMarksOpen(RollNo, Marks, , .sc)

I tried this above method but it is showing the below error.

Error #5002: Cache Error : <COMMAND>%Open+18^Library.Persistent.1

What does this mean??

I'm sure you have %OnOpen method in your class which not working properly. At least it should return status, but return nothing by now.

Comments