Run Class method under HSCUSTOM on terminal
Hi All,
I have a method like this and I want to be able to see the results on the terminal, how do I run this method on a terminal to display the results of this SQL query?
{
set oldNamespace = $Namespace
new $Namespace
set $Namespace = namespace
s timeTaken = 0, InDate = ""
#SQLCompile Select=Display
&SQL(select InDate, AVG(Time_Taken) into :InDate, :timeTaken from (select SessionId, (TimeCreated) InDate, MIN(TimeCreated) Start_Time,MAX(TimeProcessed) End_Time, DATEDIFF('ms',MIN(TimeCreated),MAX(TimeProcessed)) Time_Taken FROM Ens.MessageHeader where status = 'Completed' and Resent is null and Month(TimeCreated) = Month(current_date) group by SessionId) group by Year(InDate), Month(InDate)) new $Namespace
set $Namespace = oldNamespace
do ..SetSensor("ResponseTimeCurrentMonth",timeTaken,namespace)
}
Did you mean to make it a class method? Is SetSensor a class method?
As it is not a class method you need either to create/open an object for the class or rewrite the method as ClassMethod (instead of Method). But as the SetSensor call is also pointing to the same object (See do ..SetSensor), the simplest would be to create/open the object:
set obj=##class(Package.YourClass).%New() do obj.ResponseTimeCurrentMonth("USER")
You may also need to add some Writes to the terminal to see something. For example:
write !,"Date:",InDate write !, "time taken:",timeTaken