go to post Vitaliy Serdtsev · May 3, 2019 s delim = " ", abbrv = "" ... set abbrv = abbrv _ $e($PIECE(desc,delim,i),1,2) // But if I put w abbrv I can get "Resytorewipa"
go to post Vitaliy Serdtsev · May 3, 2019 Also I'm curious if we can set up and pass a JSON that easily too? Would be great. Certainly. Class dc.test Extends %RegisteredObject { ClassMethod MethodTest(args As %DynamicObject) { i $IsObject(args) { w args.%ToJSON(),! w:args.%IsDefined("arr") args.arr."2",! }else{ w "null",! } } ClassMethod Test() { ;d ##class(dc.test).Test() d ..MethodTest(), ..MethodTest({}), ..MethodTest({"arg1":($zts),"arg6":"hello","arr":["a",10,true,2.5674]}) } }Result: USER>d ##class(dc.test).Test() null {} {"arg1":"65136,19638.022","arg6":"hello","arr":["a",10,true,2.5674]} 1
go to post Vitaliy Serdtsev · Apr 24, 2019 First, should be so (AttachFile): s status=msg.AttachFile("F:\MyDir","myFirstFile.pdf",1,,.count) s status=msg.AttachFile("F:\MyDir","mySecondFile.pdf",1,,.count)Second, you did not specify the error text. Try the following simple MAC-example, replacing the values with your own: #include %systemInclude new try{ $$$AddAllRoleTemporaryInTry new $namespace set msg=##class(%Net.MailMessage).%New() set msg.Subject="Subject" set msg.From="from@domain" do msg.To.Insert("to@domain") do msg.TextData.Write("Hello!") $$$ThrowOnError(msg.AttachFile("F:\MyDir","myFirstFile.pdf")) $$$ThrowOnError(msg.AttachFile("F:\MyDir","mySecondFile.pdf")) set smtp=##class(%Net.SMTP).%New() set smtp.smtpserver="123.145.167.189" $$$ThrowOnError(smtp.Send(msg)) }catch(ex){ write "Error ", ex.DisplayString(),! }
go to post Vitaliy Serdtsev · Apr 23, 2019 s res=##class(%SQL.Statement).%ExecDirect(,$$$FormatText("CREATE TABLE %1 (TNAMESPACE CHAR(100),TINTERFACE CHAR(100))",$$$quote("xxxxx"_$USERNAME))) w res.%SQLCODE
go to post Vitaliy Serdtsev · Apr 16, 2019 See examples and try "Run It" in JSON_ARRAYAGG. E.g.: SELECT JSON_ARRAYAGG(Home_State) FROM Sample.Person WHERE Home_State %STARTSWITH 'A'Result: ["AR","AL","AR","AL","AL","AR","AK","AL","AR","AK","AK","AZ","AR","AR","AL"] SELECT JSON_OBJECT('state':Home_State) FROM Sample.Person WHERE Home_State %STARTSWITH 'A'Result: {"state":"AR"} {"state":"AL"} {"state":"AR"} {"state":"AL"} {"state":"AL"} {"state":"AR"} {"state":"AK"} {"state":"AL"} {"state":"AR"} {"state":"AK"} {"state":"AK"} {"state":"AZ"} {"state":"AR"} {"state":"AR"} {"state":"AL"} SELECT JSON_ARRAYAGG(JSON_OBJECT('state':Home_State)) FROM Sample.Person WHERE Home_State %STARTSWITH 'A'Result: [{"state":"AR"},{"state":"AL"},{"state":"AR"},{"state":"AL"},{"state":"AL"},{"state":"AR"},{"state":"AK"},{"state":"AL"},{"state":"AR"},{"state":"AK"},{"state":"AK"},{"state":"AZ"},{"state":"AR"},{"state":"AR"},{"state":"AL"}]
go to post Vitaliy Serdtsev · Apr 15, 2019 See %CACHE_HOME%\dev\Cache\callout\demo\czf.pdf (Section "Lists")
go to post Vitaliy Serdtsev · Apr 13, 2019 Here is a small example: select JSON_ARRAYAGG(JSON_OBJECT('ID':ID,'Age':Age,'SSN':SSN)) from (select top 3 ID,Age,SSN from sample.person)Result: [{"ID":1,"Age":59,"SSN":"502-68-5767"},{"ID":2,"Age":6,"SSN":"169-66-9969"},{"ID":3,"Age":64,"SSN":"868-61-3642"}]
go to post Vitaliy Serdtsev · Apr 10, 2019 As of release 2012.2, member names can be delimited. To create a delimited member name, use double quotes for the first and last characters of the name. Then the name can include characters that are otherwise not permitted. See Rules for Class and Class Member Names
go to post Vitaliy Serdtsev · Apr 10, 2019 Then it's better: Method Get() As %String [ CodeMode = objectgenerator, NoContext] { d:%mode="propertymethod" %code.WriteLine(" q ..Test()") q $$$OK }
go to post Vitaliy Serdtsev · Apr 10, 2019 It doesn't work for me too, there is an error #1056: Missing subscript : '}'
go to post Vitaliy Serdtsev · Apr 10, 2019 NoContext helped. What does it mean? NoContext With the same success it is possible to specify NoContext for the class: Class Test.String Extends %String [ NoContext ] { Method Get() As %String [ CodeMode = objectgenerator ] { d %code.WriteLine(" q $this.Test()") q $$$OK } }This works too btw: It doesn't work for me: MPP5376 : Method or Property 'Test' does not exist in this class.
go to post Vitaliy Serdtsev · Apr 10, 2019 Try this Class Test.String Extends %String { Method Get() As %String [ CodeMode = objectgenerator, NoContext ] { d %code.WriteLine(" q $this.Test()") q $$$OK } }
go to post Vitaliy Serdtsev · Apr 8, 2019 You can do it even easier: &sql(SELECT {fn TIMESTAMPDIFF(SQL_TSI_HOUR,CURRENT_TIMESTAMP(3),:tx)})Small example: &sql(SELECT CURRENT_TIMESTAMP(3), {fn TIMESTAMPADD(SQL_TSI_MINUTE,67,CURRENT_TIMESTAMP(3))} into :txBefore,:txAfter) w txBefore," -> ",txAfter,!! &sql(SELECT {fn TIMESTAMPDIFF(SQL_TSI_HOUR,CURRENT_TIMESTAMP(3),:txAfter)}, {fn TIMESTAMPDIFF(SQL_TSI_HOUR,:txBefore,:txAfter)} into :r1,:r2) w r1,!,r2Result: USER>d ^test 2019-04-08 08:51:34.916 -> 2019-04-08 09:58:34.916 1 1 USER>d ^test 2019-04-08 08:55:11.907 -> 2019-04-08 10:02:11.907 2 2
go to post Vitaliy Serdtsev · Apr 4, 2019 This setting does not affect users experience. Before enabling, make sure you have Username/Password and/or System_Manager set, otherwise any user will be able to manage your CSP gateway. Everything is described in detail in the link I mentioned above, so I can hardly add anything more than that.
go to post Vitaliy Serdtsev · Apr 4, 2019 Check parameter SM_Forms in the file CSP.ini. Should be SM_Forms=Enabled
go to post Vitaliy Serdtsev · Apr 4, 2019 There are two ways to define views, so I'll give you both options: /// bla-bla-bla:<ul> /// <li>Name - Person's name;</li> /// <li>SSN - Person's Social Security number. This is validated using pattern match;</li> /// <li>DOB - Person's Date of Birth.</li></ul> Class view.Person [ ClassType = view, CompileAfter = Sample.Person, DdlAllowed, Not ProcedureBlock, ViewQuery = { select Name,SSN,DOB from Sample.Person} ] { } /// This sample persistent class represents a person. /// <p>Maintenance note: This class is used by some of the bindings samples. Class Sample.Person Extends (%Persistent, %Populate, %XML.Adaptor) { ... /// bla-bla-bla:<ul> /// <li>Name - Person's name;</li> /// <li>SSN - Person's Social Security number. This is validated using pattern match;</li> /// <li>DOB - Person's Date of Birth.</li></ul> Query viewPerson() As %SQLQuery [ SqlView, SqlViewName = viewPerson ] { select Name,SSN,DOB from Sample.Person } ... } Now take a look at these classes from Documatic.
go to post Vitaliy Serdtsev · Apr 2, 2019 Look in the direction of the DocBook that is used in the embedded InterSystems documentation. There is support for highlighting for many languages: Caché Basic, Caché ObjectScript, Caché Class Definition Syntax, etc. Very long ago (2012), I wrote an article on this topic, but it is in Russian (machine translation).
go to post Vitaliy Serdtsev · Mar 28, 2019 See: select * from %Library.SQLCatalog_SQLReservedWords() $SYSTEM.SQL.IsReservedWord(word)