go to post Vitaliy Serdtsev · Dec 29, 2017 Undefined variable and the variable contains "" (null) is two different situations, e.g. (see $DATA): kill myObj write $data(myObj),! ; -> 0 set myObj=$$$NULLOREF write $data(myObj),! ; -> 1In your case it would be better to use $IsObject: kill myObj write $IsObject(myObj),! ; -> 0 set d=$$$NULLOREF write $IsObject(myObj),! ; -> 0 set myObj={} write $IsObject(myObj),! ; -> 1Accordingly, should be do $$$AssertTrue('$IsObject(myObj), "myObj is null")
go to post Vitaliy Serdtsev · Dec 29, 2017 You are right, the macro $$$NULL present only in %sqlMigration.inc and this is not the file that developers often include to its project.I prefer to use the macro $$$NULLOREF/$$$NULLOID from %occExtent.inc, which is available by default in the class that inherits from %Library.Base, and for routines is enough to include %systemInclude.inc.
go to post Vitaliy Serdtsev · Dec 28, 2017 Why so difficult?This similarly following condition: WHERE ( year(current_date) - year(DOB) ) >= 13It Besides above was already indicated, why does not follow to use such a code, for example: select datediff(year, todate(to_char({d '1990-12-31'},'YYYY')||':1','YYYY:MM'), -- birthday todate(to_char({d '2003-01-01'},'YYYY')||':1','YYYY:MM') -- report date )This gives an incorrect result - 13, although it should be 12.
go to post Vitaliy Serdtsev · Dec 26, 2017 Here's another way (without PlaceAfter): Class Macro.Child Extends Macro.Parent { ClassMethod %inc() [ Internal, Private ] { #include Child } ClassMethod Test() { write "Class: " , $classname() , ! , "Value: " , $$$name } }
go to post Vitaliy Serdtsev · Dec 26, 2017 The key difference of $classmethod is runtime: $CLASSMETHOD permits a ObjectScript program to invoke an arbitrary class method in an arbitrary class. Both the class name and the method name may be computed at runtime or supplied as string constants.proof
go to post Vitaliy Serdtsev · Dec 26, 2017 Class include is not required (and does not seem to affect anything) and can be omitted Yeah, I just forgot to delete that line.
go to post Vitaliy Serdtsev · Dec 26, 2017 Then this: Include Child Class Macro.Child Extends Macro.Parent { ClassMethod first() { #include Child } ClassMethod Test() [ PlaceAfter = first ] { write "Class: " , $classname() , ! , "Value: " , $$$name } }or this: ClassMethod Test() { #include Child write "Class: " , $classname() , ! , "Value: " , $$$name }
go to post Vitaliy Serdtsev · Dec 26, 2017 Macro.Parent.cls: Include Parent Class Macro.Parent { ClassMethod Test() { write "Class: " , $classname() , ! , "Value: " , $$$name } }Macro.Child.cls: Include Child Class Macro.Child Extends Macro.Parent { ClassMethod Test() { write "Class: " , $classname() , ! , "Value: " , $$$name } }Parent.inc: #ifndef name #define name "Parent" #endif nameChild.inc: #define name "Child"Result: >do ##class(Macro.Parent).Test() Class: Macro.Parent Value: Parent >do ##class(Macro.Child).Test() Class: Macro.Child Value: Child
go to post Vitaliy Serdtsev · Dec 19, 2017 This data is saved in the registry. You can even save greater value than allowed by the program (see screenshot).Example of work with the registry directly from Caché Object Script can be found here.
go to post Vitaliy Serdtsev · Dec 16, 2017 For better performance you should make a few changes: add an index on DOB field rebuild the index and run TuneTable modify the query select DOB from HSAA.Patient where dob<=dateadd('yy',-13,current_date) or dob between todate((year(current_date)-13)||'0101','yyyymmdd') and todate((year(current_date)-13)||'1231','yyyymmdd') The result will pleasantly surprise you.
go to post Vitaliy Serdtsev · Dec 15, 2017 Hi Marco. CSVTOCLASS creates a new class if it doesn't already exist and then it calls the Import method. Since you already have created the class, it is not created, but there is no Import method, so nothing works. Solution: delete all previously created classes: ZenImport.Country, TestCsv.Csv, etc. run in terminal: USER>set rowtype = "Code VARCHAR(2),Name VARCHAR(9)" USER>set filename = "c:\temp\Country.csv" USER>do ##class(%SQL.Util.Procedures).CSVTOCLASS(2, .rowtype, filename,";",,,"Test.CSV") run in Portal: select * from Test.CSVopen and see the class "Test.CSV". Profit!!!
go to post Vitaliy Serdtsev · Dec 14, 2017 select DOB from sample.person -- or HSAA.Patient where (tochar(current_date,'YYYYMMDD')-tochar(DOB,'YYYYMMDD'))\10000>=13 or ((year(current_date)||'1231')-tochar(DOB,'YYYYMMDD'))\10000=13
go to post Vitaliy Serdtsev · Dec 14, 2017 Never use DATEDIFF for accurate calculation of the age since days and months here are not taken into account. See example
go to post Vitaliy Serdtsev · Dec 5, 2017 In this case $system.SQL.DATEDIFF is not suitable: USER>w $system.SQL.DATEDIFF("yy", $zdh("30.12.1990",4), $zdh("01.01.1991",4)) 1 USER>w ($ZD($zdh("01.01.1991",4),8)-$ZD($zdh("30.12.1990",4),8))\10000 0
go to post Vitaliy Serdtsev · Dec 5, 2017 See Sample.Person in "SAMPLES". /// Person's age.<br> /// This is a calculated field whose value is derived from <property>DOB</property>. Property Age As %Integer [ Calculated, SqlComputeCode = { Set {Age}=##class(Sample.Person).CurrentAge({DOB})}, SqlComputed, SqlComputeOnChange = DOB ]; /// This class method calculates a current age given a date of birth <var>date</var>. ClassMethod CurrentAge(date As %Date = "") As %Integer [ CodeMode = expression ] { $Select(date="":"",1:($ZD($H,8)-$ZD(date,8)\10000)) }
go to post Vitaliy Serdtsev · Nov 28, 2017 The default ciphersuite string has changed to include new options and is now: ALL:!aNULL:!eNULL:!EXP:!SSLv2 So the documentation is outdated? The default for a Caché configuration is TLSv1:SSLv3:!ADH:!LOW:!EXP:@STRENGTH which breaks down into the following group of colon-separated statements: <...>
go to post Vitaliy Serdtsev · Nov 17, 2017 All correctly, this is what I had in mind.Quote:The Find Global String page enables you to find a given string in the subscripts1 or in the values2 of selected3 globals. You can select all the globals of the namespace. In this case, the search will be performed across the database. In the search results you will get including the name of global.