Can you try this :

...
set mysqlstat="select * from file.Log where ConfigName='hhhhhhhhhhh"
set sr=##class(%SQL.Statement).%ExecDirect(,mysqlstat)
if sr.%SQLCODE=0 {
  set file="/tmp/temp.txt"  ;or any existing directory path + file name
  open file:"wns":1 Else  Write "could not open file",!
  If $Test {
    use file
    do sr.%Display()
    close file
  }
}
halt
EOM

You should preferably put all the code between znspace... and halt in a routine or class method, and just call it from the script.

If you are using %SQL.Statement, there are other methods that directly output to files :
(https://docs.intersystems.com/iris20212/csp/documatic/%25CSP.Documatic.c...)


method %Display(pDelimiter As %String = $Char(9))

Display the contents of this object on the current device

• method %DisplayFormatted(pFormat As %String = -1, pFileName As %String(MAXLEN="")="", ByRef pMessages As %SQL.Manager.Messages = "", ByRef pFilesUsed As %String(MAXLEN="")=0, pTranslateTable As %String(MAXLEN="")="")

Display the contents of the result object. If formatted display is available then format the results using the requested format and, if appropriate, open the formatted results using the host OS. The output is directed to one or more files and messages are placed in a result set object. All file names used are returned in an array.

Parameters

Name Description
pFormat

The format applied to the result content. This parameter is also used to determine the file name extension.

Supported formats are:

-1 %Display() format
0 XML
1 HTML
2 PDF (requires a renderer such as FOP)
99 TXT
100 CSV

If pFormat is specified as any number not listed above then it will default to TXT.

pFormat can also be specified as XML, HTML, PDF, TXT or CSV.

pFileName

The base file name to be used to generate actual file names used for output. If no value is specified then a file name will be generated, using the TEMP folder defined for the Cache instance. This value is not expected to include an extension. An extension is added to this value to form the actual file used. Also, if nested results exist then a number is appended to the file name specified to produce a unique name for each result.

pMessages

Instance of a system result set class. If no value is passed then the system message result class is instantiated. This parameter is passed by reference. It is up to the caller to process the result set oref that is returned. pMessages.Count() returns the number of messages contained in the result set. pMessages.%Display() will display the messages on the current device. pMessages.%DisplayFormatted() is also implemented and can be used to display the messages using the selected format.

pFilesUsed

This pass-by-reference parameter will contain the number of files used to display the result content and the name of each file. pFilesUsed is the number of files and pFilesUsed(file_number) is the name of the file. The sequence of the files is the same sequence as the results are processed. For simple result objects, there is a single file. For context objects that can contain result set sequences, the results are output in the order they are returned and the files used are present in pFilesUsed in that same order.

pTranslateTable

This is the translate table used for the output files when the format is CSV or TXT. This parameter is optional.

Ok, this is a test i wrote to add some basic source control (auto save of class and manually exporting the current project). It shows how you can add 2 menu items.
Don't  forget to activate the source control class for a namespace in the portal (admin-config-additional settings-source control)
 

Class Studio.Extension Extends %Studio.Extension.Base
{ XData Menu
{
<MenuBase>
<Menu Name="GIT" Type="0">
<MenuItem Name="Directory Setting"/>
<MenuItem Name="Export Current Project"/>
</Menu>
</MenuBase>
} /// Perform any login step here.
Method Login(Name As %String, Password As %String) As %Status
{
Write "==============================================================================================",!
Write "= Welcome ",$Get(Name),", this namespace is under source control by class Studio.Extension",!
Write "= Source files are saved in ",$Get(^SourceControl(0,$UserName,"GIT_Dir")),!
Write "==============================================================================================",!
Set ^SourceControl($J,"currentProject")=""
Quit $$$OK
} Method UserAction(Type As %Integer, Name As %String, InternalName As %String, SelectedText As %String, ByRef Action As %String, ByRef Target As %String, ByRef Msg As %String, ByRef Reload As %Boolean) As %Status
{
If $Piece($Get(InternalName),".",*)="PRJ" {
Set ^SourceControl($J,"currentProject")=$Piece(InternalName,".",1,*-1)
}
;Write "StudioExtension: Loading ",$Get(InternalName)," (",$Get(Type),"-",$Get(Name),"), current project is ",$Get(^sourcecontrol($J,"currentProject")),!
If Type=0 Do ..ExecuteMenu(Name, .Action, .Target, .Msg)
Quit $$$OK
} Method ExecuteMenu(Name As %String, ByRef Action As %String, ByRef Target As %String, ByRef Msg As %String)
{
If Name="GIT,Directory Setting" {
Set Target="Directory for GIT source control"
Set Msg=$Get(^SourceControl(0,$UserName,"GIT_Dir"))
Set Action=7
ElseIf Name="GIT,Export Current Project" {
Set Target="Export Current Project"
Set Msg=$Get(^SourceControl($J,"currentProject"))
Set Action=7
}
} Method AfterUserAction(Type As %Integer, Name As %String, InternalName As %String, Answer As %Integer, Msg As %String = "", ByRef Reload As %Boolean) As %Status
{
#Dim project, dir as %String ;Write Type,Name,InternalName," : "
;Write "You answered ",$Get(Answer) ;1=yes, 0=no, 2=cancel
;Write "with message ",$Get(Msg),!
If Answer=1,Type=0 {
If Name="GIT,Export Current Project" {
Set project = Msg
Set objProject = ##class(%Studio.Project).%OpenId(project)
If objProject'="" {
Set dir = $Get(^SourceControl(0,$UserName,"GIT_Dir"))
If dir="" {
Write !,"StudioExtension: Please set GIT directory first"
else {
If $E(dir,*)'="\" Set dir=dir_"\"
Do objProject.Export(dir_project_$ZDate($H,8)_".xml")
}
else {
Write !,"StudioExtension: Project does not exist !"
}
Set objProject = ""
ElseIf Name="GIT,Directory Setting" {
Set ^SourceControl(0,$UserName,"GIT_Dir") = Msg
Write !,"StudioExtension: GIT Directory Saved"
}
} Quit $$$OK
} /// Called after the compile of the item is done.
Method OnAfterCompile(InternalName As %String) As %Status
{
#Dim dir, separator, items, extension, fullFileName as %String Set dir = $Get(^SourceControl(0,$UserName,"GIT_Dir"))
If dir="" {
Write !,"StudioExtension: ","No directory setup to save source code"
else {
Set separator = $Select($ZV["Windows":"\",1:"/")
If dir'="", $E(dir,*)'=separator Set dir=dir_separator
Set extension=$Piece(InternalName,".",*)
Set dir=dir_extension_separator
Set fullFileName=dir_$Replace($Piece(InternalName,".",1,*-1),".",separator)_".xml"
Do ##class(%File).CreateDirectoryChain($Piece(fullFileName,separator,1,*-1)) If 0 {  ;do not export as .xml file for Git :
Set items(InternalName)=""
Do $system.OBJ.Export(.items,fullFileName)
Write !,"StudioExtension: ",InternalName_" saved as "_fullFileName
} If $Piece(InternalName,".",*)="CLS" {
Set $Piece(fullFileName,".",*) = "cls"
If $system.OBJ.ExportUDL(InternalName,$Replace(fullFileName,".xml",".cls")) {
Write !,"StudioExtension: ",$Piece(InternalName,".",1,*-1)," saved as ",fullFileName
else {
Write !,"StudioExtension: ","Error while saving "_$Piece(InternalName,".",1,*-1)," as ",fullFileName
}
}
}
Quit $$$OK
} }
 

Hi Muhammad,

Create following class :

Class Test.Json
{

ClassMethod Get(date = "24-09-2021", debug = 0) As %String
{
  #Dim status as %Status
  #Dim response as %Stream
  #Dim jsonResponse as %DynamicObject Set objHttp = ##class(%Net.HttpRequest).%New()
  Set objHttp.Server="api.aladhan.com"
  Set objHttp.Https=0
  Do objHttp.SetParam("date",date)
  Set status = objHttp.Send("GET","v1/gToH")
  If status'=1 Do $SYSTEM.OBJ.DisplayError(status) Quit ""
  If objHttp.HttpResponse'="" Do
  Set response = objHttp.HttpResponse.Data
  Set jsonResponse = ..GetResponse(response)
  If debug Write jsonResponse.data.hijri.%ToJSON(),!
  Return jsonResponse.data.hijri.date
}

ClassMethod GetResponse(response As %Stream, del As %String = "") As %DynamicObject
{
  #Dim jsonStr as %String = ""
  If response'="" {
    Do response.Rewind()
    While 'response.AtEnd {
      Set jsonStr = jsonStr _ response.ReadLine() _ del
    }
  }
  Quit {}.%FromJSON(jsonStr)
}

}

and call it like :

USER>set hijri=##class(Test.Json).Get()
 
USER>write hijri
16-02-1443
USER>set hijri=##class(Test.Json).Get(,1)
{"date":"16-02-1443","format":"DD-MM-YYYY","day":"16","weekday":{"en":"Al Juma'a","ar":"الجمعة"},"month":{"number":2,"en":"Ṣafar","ar":"صَفَر"},"year":"1443","designation":{"abbreviated":"AH","expanded":"Anno Hegirae"},"holidays":[]}
 
USER>Write ##class(Test.Json).Get("01-08-2021")
22-12-1442
USER>

This has probably to do with underscores ( _ ) in variable/method names. (not allowed in object script, but used with callbacks in the (deprecated) product VISM (or also called Cache Direct, hence the CD and CalBk in the error)
I get a similar error when doing :

%SYS>set _abc=1
 
<FUNCTION>SetProp+2^%CDCalBk
%SYS 3d1>

From the documentation :

Invalid Names

A local variable name that does not follow the above naming conventions generates a error. There is one exception: if an invalid variable name begins with an underscore character followed by a letter, the system generates a <_CALLBACK SYNTAX> error. (Note the underscore character within the error name.) For example, SET _abc = 123 or SET x = _abc. This is because Caché identifies these names as VISM control names, rather than local variable names.

Do you use CSP pages or REST (through portal or other applications) ? It uses a grace period that can hold a license slot longer than the actual login time.

You can look at the license usage in the Management Portal :
- Click on View System Dashboard, in Licensing tab :

You can click on Current License Use, and click on the bottom of the page on 'Click here for more details' to go to the License Usage page (also accessible via System Operation -> License Usage)

You can view the same figures in terminal by using Do $system.License.ShowSummary()
(Look at Do $system.License.Help() for other methods to show license stats.

Hi Hansel,

Temp should only grow because of use of temporary globals. (^IRIS.temp, ^mtemp, or any other global explicitly mapped to IRISTEMP)
In my experience, sudden growth of temp is mostly due to an SQL query that is doing a join or order of non-indexed columns.
When you restart Iris, you could delete the iristemp (it will recreate it), you can also set a param to truncate it automatically at startup:
https://docs.intersystems.com/irislatest/csp/docbook/DocBook.UI.Page.cls...
 

Hi Anthony,

Look at the doc for the property EntityBody, you can do something like :

Set body = { "MyKey":"MyValue" }
Do httpRequest.EntityBody.Write(  body.%ToJSON() )

 property EntityBody as %GlobalBinaryStream;

When an Entity-Body is included with a message, the data type of that body is determined via the header fields Content-Type and Content- Encoding. These define a two-layer, ordered encoding model.

This is a stream so to insert into this stream use:

	Do oref.EntityBody.Write("Data into stream")

Hi Yone,

what version are you using ? From Caché/Ensemble 2016.2 you could create your json directly like :

Set body = {
     "app_id""e47322de-64c8-43c5-a1b7-42aa6409eb48",
     "headings"{"en":"Cita Atencion Primaria","es":"Cita Atencion Primaria"},
     "subtitle"{"en":"C.P. ISORA","es":"C.P. ISORA"},
     "contents"{"en""Next appointment""es""Siguiente cita"},
     "data":{
                "centro""C.P. ISORA",            
                "fecha""yyyy/mm/dd",       
                "hora""hh:mm",
                "profesional""nombre del profesional",
                "nomUsuario""nombre del usuario",
                "codcita""idCita",
                "sepuedeborrar"1
     },
     "include_player_ids"["2b3a6be7-5475-4871-b3be-a50eb2ec6034"]
}
Do httpRequest.EntityBody.Write(body.%ToJSON())

It all depends from which backup and journal files you start the recovery.

You need to start from a backup  & all journal files from before your event that killed the data (and stop the restore just before that event, which i assume is  11/14/2019 15:18:56). What happened on this time : did you kill some data or remove the class ?

It seems that the restore did not fully restored the class definition : can you go into studio and recompile the class ?

In the class definition, you will find the actual global names where the data is stored (by default it will be ^User.MemberD and ^User.MemberI (and possibly ^User.MemberS). Do you have these globals after the restore ?

Hi Everardo,

I have seen the error, but not in testing ensemble messages :

USER>Write _test1
 
<FUNCTION>GetProp+2^%CDCalBk
USER 3e1>

variables preceded by _ (underscore) are only to be used in Caché Direct (VISM) programs.

Are you running any code that uses too much underscores ?

For example :

USER>set var1=1
 
USER>set var2="a"_var1
 
USER>set var2="a"__var1  ;two underscores
 
<FUNCTION>GetProp+2^%CDCalBk
USER 3e1>

Are you pointing the filestream to the correct file : is there any data in the filestream (you are using \Temp\GaganTest : it will use the same drive as the one where your database is located, also no extension is mentioned)

You can set a timeout (Set ftp.Timeout = 100) if the ftp server times out when uploading big files.

The file size will not effect your cache.dat size.