go to post Vitaliy Serdtsev · Jul 1 In addition to the above: Dynamic SQL Using Older Result Set Classes
go to post Vitaliy Serdtsev · Jun 27 Also take a look at the event logging capability at the CSP-Gateway level: Event Logging Parameters
go to post Vitaliy Serdtsev · Jun 26 The terminal output in a log file is in Unicode UTF8 format and for further log processing Ansible is not able to read the format. What error does Ansible give you? I'm not familiar with Ansible, but it seems to me that it shouldn't have any problems reading UTF-8: https://github.com/NixOS/nixpkgs/issues/223151#issuecomment-1484053350
go to post Vitaliy Serdtsev · Jun 26 Hi! You need first convert the formatted date and time string to a standard timestamp. Unfortunately, the built-in TO_TIMESTAMP function is not suitable for your case. Next, you need determine whether the time zone will be taken into account or not. For tests, you can use https://www.timestamp-converter.com / (ISO 8601 section). Here is a small example: Class dc.test Extends %RegisteredObject { ClassMethod ISO2TS( strISO As %String, withTZ As %Boolean = 0) As %TimeStamp [ SqlProc ] { s tsUTC=##class(%TimeStamp).XSDToLogical(strISO) q $s(withTZ:##class(%UTC).ConvertUTCtoLocal(tsUTC),1:tsUTC) } ClassMethod Test() { f s="2024-06-23T06:03:00Z","2024-06-23T06:03:00-02:45" { s iso=s, utc=##class(%TimeStamp).XSDToLogical(iso), tz=##class(%UTC).ConvertUTCtoLocal(utc) w $$$FormatText("ISO 8601 = %2%1Date Time (UTC) = %3%1Date Time (your time zone) = %4%1",$$$NL,iso,utc,tz),! } } }Result (for me): USER>d ##class(dc.test).Test() ISO 8601 = 2024-06-23T06:03:00Z Date Time (UTC) = 2024-06-23 06:03:00 Date Time (your time zone) = 2024-06-23 09:03:00.000 ISO 8601 = 2024-06-23T06:03:00-02:45 Date Time (UTC) = 2024-06-23 08:48:00 Date Time (your time zone) = 2024-06-23 11:48:00.000 Using via SQL: SELECT YEAR(ts) "YEAR", MONTH(ts) "MONTH", DAY(ts) "DAY", {fn HOUR(ts)} "HOUR", {fn MINUTE(ts)} "MINUTE", {fn SECOND(ts)} "SECOND" FROM (SELECT dc.test_ISO2TS('2024-06-23T06:03:00Z',0) ts)
go to post Vitaliy Serdtsev · Jun 24 See "Customizing the Terminal Application": Network Encoding Physical Character Setting
go to post Vitaliy Serdtsev · Jun 24 Try this example Class User.myclass Extends %Persistent { Property myVECTOR As %Vector(CAPTION = "Vector", DATATYPE = "INTEGER"); Property myProperty As %String(MAXLEN = 40) [ Required ]; ClassMethod GetEmbedding1(sentences As %String) As %String { q "2,4,6,8" } ClassMethod GetEmbedding2(sentences As %String) As %DynamicObject { q [1,3,5,7,9] } ClassMethod Test() { d ..%KillExtent() set data=##class(User.myclass).%New() set data.myProperty ="anything 1" set data.myVECTOR=##class(User.myclass).myVECTORDisplayToLogical(##class(User.myclass).GetEmbedding1("this is my text")) d $system.OBJ.DisplayError(data.%Save()) ; OR set data=..%New() set data.myProperty ="anything 2" set data.myVECTOR=data.myVECTORDisplayToLogical(..GetEmbedding2("this is my text")) d $system.OBJ.DisplayError(data.%Save()) zw ^User.myclassD } } USER>d ##class(User.myclass).Test() ^User.myclassD=2 ^User.myclassD(1)=$lb("",{"type":"integer", "count":4, "length":4, "vector":[2,4,6,8]} ; <VECTOR>,"anything 1") ^User.myclassD(2)=$lb("",{"type":"integer", "count":5, "length":5, "vector":[1,3,5,7,9]} ; <VECTOR>,"anything 2")
go to post Vitaliy Serdtsev · Jun 6 SELECT LIST(Diagnose) FROM (SELECT TOP ALL MRDIA_ICDCode_DR->MRCID_Desc Diagnose FROM SQLUser.MR_Diagnos WHERE MRDIA_MRADM_ParRef=123456789 ORDER BY MRDIA_DiagnosisType_DR ASC)
go to post Vitaliy Serdtsev · May 28 Regional preferences have nothing to do with it. From the conditions of the task it is unclear how many mouths, noses and eyes are allowed in one emoticon (based on physiology one at a time (we do not count pathologies)): ")", "))", ")D", ")))", "xD", "xDD"
go to post Vitaliy Serdtsev · May 27 Additional explanations are required. It is not entirely clear from the description whether one smiling mouth is acceptable, for example ")", "D", etc., and also why "))" is a valid smiley face.
go to post Vitaliy Serdtsev · May 15 How would you like to solve it, using ObjectScript? For example, like this: ClassMethod Test() { s C = 2500, r = 0.5, S = 3000000, T = 35, W = 5 w $$maxWeddingCost(C, r, S, T, W),! ; => 93278.3281405256664 s S = 2000000 w $$maxWeddingCost(C, r, S, T, W),! ; => 174425.0762746580325 maxWeddingCost(C,r,S,T,W) s r=r/100,a=1+r**12,b=a**(T-W) q a**W-1/r*C+$$LEAST^%qarfunc(0,b-1/r*C-S/b) }
go to post Vitaliy Serdtsev · May 15 We have our own challenge with very specific conditions and goals: #Code GolfAnd what is the purpose of your challenge, I do not quite understand: speed, code size, etc? Rewriting the code in ObjectScript is too simple and not interesting. esthetic() ClassMethod esthetic(num = 441) As %String { set estheticBases="" for base=2:1:10{ set digits = $$toBase(num, base) if $$isEstheticInBase(digits) set estheticBases=estheticBases_$listbuild(base) } quit $listtostring(estheticBases) toBase(n,base) ; Convert number n to a given base and return the digits as a list. set digits="" while n { set digits=(n#base)_digits, n=n\base } quit digits isEstheticInBase(digits) ; Check if the given list of digits is esthetic. for i=2:1:$length(digits){ if $zabs($extract(digits,i)-$extract(digits,i-1))'=1 { return 0 } } return 1 }
go to post Vitaliy Serdtsev · May 15 The calculateTotalSavingsAtTime method can be shortened because initialPrincipal is always 0: public static double calculateTotalSavingsAtTime(double initialPrincipal, double r, double monthlyDeposit, int timeMonths) { return monthlyDeposit * ((Math.pow(1 + r, timeMonths) - 1) / r) + initialPrincipal * Math.pow(1 + r, timeMonths); }
go to post Vitaliy Serdtsev · May 14 Try this: ClassMethod GetTreeInfo( pRoot As %String, Output pTree, ByRef pParms) As %Status { Set MyId=..GetId,pos=1 &Sql(Select Name,ID into :name,:id from MSDS_COM.Loc where Parent=:MyId) Set:SQLCODE (name,id)="" if pRoot="" { Set pTree(0,"ch",1) = "" Set pTree(1) = $LB(name,id,1,"","") } Quit $$$OK }For further examples, see the class ZENTest.DynaTreeTest in the SAMPLES namespace.
go to post Vitaliy Serdtsev · May 14 Through %ZEN.proxyObject is unlikely to work, since the q parameter cannot be disabled in this case q - output numeric values unquoted even when they come from a non-numeric property Use your own class, for example: Class dc.proxyObject Extends %RegisteredObject { Property ID As %VarString; }set object = ##class(dc.proxyObject).%New() set object.ID = 123456 set x = ##class(%ZEN.Auxiliary.jsonProvider).%WriteJSONStreamFromObject(.json,object,,,,"aelotw")Output: { "ID":"123456" }
go to post Vitaliy Serdtsev · Apr 11 I do not observe any differences in the behavior of xDBC and Portal. Given: Class dc.test Extends %Persistent { Property s1 As %String(MAXLEN = 2, TRUNCATE = 1); Property s2 As %String(MAXLEN = 2); } insert into dc.test(s1,s2)values('abc','ab') Result ID s1 s2 1 ab ab insert into dc.test(s1,s2)values('abc','abc') Result for any JDBC/ODBC tools (DBVisualizer, SQL Data Lens, etc.): [SQLCODE: <-104>:<Field validation failed in INSERT>] <Field 'dc.test.s2' Truncation (Varchar Value: 'abc ...' Length: 3) > maxlen: (2)>] Result for Management Portal: [SQLCODE: <-104>:<Field validation failed in INSERT>] [%msg: <Field 'dc.test.s2' (value 'abc') failed validation>]
go to post Vitaliy Serdtsev · Apr 10 Check your TRUNCATE parameter. Common Parameters:TRUNCATE TRUNCATE — Specifies whether to truncate the string to MAXLEN characters, where 1 is TRUE and 0 is FALSE. This parameter is used by the Normalize() and IsValid() methods but is not used by database drivers. Class dc.test Extends %Persistent { Property s1 As %String(TRUNCATE = 1); Property s2 As %String; ClassMethod Test() { d ..%KillExtent(,$$$YES) s t=..%New() s t.s1=$tr($j("",51)," ","a") s sc=t.%Save() w "s1: ",$s($$$ISERR(sc):$system.Status.GetErrorText(sc),1:"OK"),! s t=..%New() s t.s2=$tr($j("",51)," ","a") s sc=t.%Save() w "s2: ",$s($$$ISERR(sc):$system.Status.GetErrorText(sc),1:"OK"),! } } USER>d ##class(dc.test).Test() s1: OK s2: ERROR #7201: Datatype value 'aaaa..aa' length longer than MAXLEN allowed of 50 > ERROR #5802: Datatype validation failed on property 'dc.test:s2', with value equal to "aaaa..aa" The same error occurs in the Management Portal.
go to post Vitaliy Serdtsev · Apr 10 MAXLEN is not applicable for %GlobalCharacterStream (Blob). You will get compilation error #5480
go to post Vitaliy Serdtsev · Apr 4 select lpad(s\3600,2,0)||':'||lpad(s\60#60,2,0)||':'||lpad((s)#3600#60,2,0) diff from (select DATEDIFF('s','2024-04-01 09:13:46','2024-04-01 11:11:44') s)
go to post Vitaliy Serdtsev · Apr 2 I noticed that you are using the {Stream} syntax, which is typical for trigger code or calculated field. Could you check the following code at your place: Class dc.test Extends %Persistent { Property stream As %GlobalCharacterStream; Trigger NewTrigger1 [ Event = INSERT ] { i $IsObject({stream}) { s t={stream} s ^||tmp=t.Size } } ClassMethod Test() { d ..%KillExtent(,$$$YES) s f=##class(%Stream.FileBinary).%New() d f.LinkToFile("C:\test.jpg") &sql(insert into dc.test(stream) values(:f)) i 'SQLCODE { &sql(select CHAR_LENGTH(stream) into :len from dc.test where %id=1) w len," ",^||tmp,! } } }I have saved a 16 MB file without any problems: USER>d ##class(dc.test).Test() 16446809 16446809