Vivek Ranjan · Oct 5, 2018 go to post

Yes both methods are running parallel and embedded SQL and object access are combined. My question is  object oid of a row is stored inmemory.  When you do some operation with embedded SQL the updated disk data is not updated automatically in the inmemory object. Means the open I'd should be explicitly reloaded to get the latest data from row.

The real question is whether I should kill the object oid then open it or don't kill the open Id object and just do the reload.

Vivek Ranjan · Feb 21, 2018 go to post

 ClassMethod  Createtask() As %Status
{
Set tStatus = $$$OK
Try 
{
Set tTaskName = "Task Name"
Set tTaskClass = "Task.Classname"
Set tTaskDesc = "Task Desc"
Set tSql="select ID from %SYS.Task where NameSpace = ? and TaskClass = ?"
Set tRS = ##class(%SQL.Statement).%ExecDirect(,tSql, $Namespace, tTaskClass)
If (tRS.%Next())
{
 "Updating Task: "_tTaskName
Set tTaskObj = ##class(%SYS.Task).%OpenId(tRS.ID)
}
Else 
{
"Creating Task: "_tTaskName
Set tTaskObj = ##class(%SYS.Task).%New()
}
Set tTaskObj.NameSpace = $Namespace
Set tTaskObj.Name = tTaskName
Set tTaskObj.TaskClass = tTaskClass
Set tTaskObj.Description = tTaskDesc
Set tTaskObj.RunAsUser = "_system"
//Run task daily at 2 am
Set tTaskObj.TimePeriod = tTaskObj.TimePeriodDisplayToLogical("Daily")
Set tTaskObj.TimePeriodEvery = 1 // Every day (7 days a week)
Set tTaskObj.DailyFrequency = tTaskObj.DailyFrequencyDisplayToLogical("Once") // Run once daily
Set tTaskObj.DailyStartTime = (60*60*2) // 2:00am
"Saving task"
Set tStatus = tTaskObj.%Save()
$$$ThrowOnError(tStatus)
"Saved task ID: "_tTaskObj.%Id()
Do $SYSTEM.Task.Resume(tTaskObj.%Id())
 
}
Catch ex {
Set tStatus = ex.AsStatus()
}
Quit tStatus
}

Vivek Ranjan · Mar 29, 2018 go to post

Add the reference to cache provider for .net

using InterSystems.Data.CacheClient;


CacheDataReader dr;

using (CacheConnection con = new CacheConnection())
   {
             con.ConnectionString = "Server=" + Servername+ ";" + "Port=1972; Namespace=Namespace;" + "Password=" + Password + ";" + "User ID=" + UserName + ";";

             CacheCommand cmd;
             cmd = new CacheCommand("select * from table", con);
              con.SetQueryRuntimeMode(InterSystems.Data.CacheTypes.QueryRuntimeMode.DISPLAY);
              con.Open();
              dr = cmd.ExecuteReader();
             while (dr.Read()){ // do your stuff }
}

Vivek Ranjan · Oct 23, 2018 go to post

##class(Ens.Rule.FunctionSet).Pad(inputString,LengthofYourString,0)     

 Eg: w ##class(Ens.Rule.FunctionSet).Pad(1,-4,0)    

0001