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)
go to post Vitaliy Serdtsev · Mar 20, 2019 For example, you can export them all to a single file: SAMPLES>d $system.OBJ.ExportPattern("*.dfi","c:\exportAllDFI.xml",,,"UTF8")You can get the list as follows (doc): select Name from %Library.RoutineMgr_StudioOpenDialog('*.dfi')
go to post Vitaliy Serdtsev · Mar 20, 2019 First, I would not use the input values directly in the query text, but would use Input Host Variables Second, if it is necessary, it is more elegant to use the following syntax: Set stmt = ##CLASS(%SQL.Statement).%New() Set query = $$$FormatText("Select Val1, Val2 FROM Table WHERE Val1=%1",$$$quote("SomeCondition"))Ideally these should be : &SQL(SELECT Val1, Val2 INTO :val1, :val2 FROM Table WHERE Val1='SomeCondition') This is and now works: &SQL(SELECT Val1, Val2 INTO :val1, :val2 FROM "Table" WHERE "Val1"='SomeCondition')
go to post Vitaliy Serdtsev · Mar 14, 2019 Let's try to guess the return value of method t1(). Is that supposed to be hard? I immediately visually determined the result 20. To be honest I don't really understand the point which the author wanted to convey. Maybe it's the lack of English. In this case, the t3 method code is equivalent to the following code: ClassMethod t3(ByRef pA, ByRef pB) [ ProcedureBlock = 1 ] { set pA=4, pB=5 set x=$increment(pA)*$increment(pB) }PS: by the way, absolutely nothing will change fundamentally if you replace "return" with "quit" (and "ByRef" with "Output").
go to post Vitaliy Serdtsev · Mar 12, 2019 Hi Ponnumani. I would like to make a number of clarifications: VALUELIST = "A A- B B- O" -> VALUELIST = " A A- B B- O" it is necessary to consider the order of the fields in the global on the basis of Storage. For example, I have following Storage: <Data name="samplexlsconversionDefaultData"> <Value name="1"> <Value>%%CLASSNAME</Value> </Value> <Value name="2"> <Value>name</Value> </Value> <Value name="3"> <Value>DOB</Value> </Value> <Value name="4"> <Value>address</Value> </Value> <Value name="5"> <Value>PhoneNumber</Value> </Value> <Value name="6"> <Value>BloodGroup</Value> </Value> </Data> need to add check for the presence of double quotes in strings, e.g. bla"bla the date format for CSV should not be in the internal Caché format, because the date 37893 to users of other system/DBMS nothing says unlike e.g. 1944-09-30. I still prefer to use built-in tools when they are there, rather than reinventing the wheel. Class User.samplexlsconversion Extends (%Persistent, %Populate) { Property name As %String; Property DOB As %Date; Property address As %String; Property PhoneNumber As %Numeric; Property BloodGroup As %String(VALUELIST = " A A- B B- O"); ClassMethod TestExport2CSV() { d ..%KillExtent() d ..Populate(1000) s tmp=..%OpenId(1) s tmp.name=tmp.name_$c(34) d tmp.%Save() s tmp=..%OpenId(2) s tmp.name=$c(34)_tmp.name_$c(34) d tmp.%Save() s mgr = ##class(%SQL.Export.Mgr).%New() s mgr.FileName = "c:\Temp\test.csv" s mgr.ClassName = ..%ClassName(1) s mgr.TableName = $$$CLASSsqltablename($$$gWRK,mgr.ClassName) s mgr.Delimiter = "," s mgr.StringQuote = $c(34) s mgr.DateFormat = 3 s mgr.TimeFormat = 1 s mgr.TimeStampFormat = 1 s mgr.NoCheck = $$$YES s mgr.HasHeaders = $$$YES s cols="Name:S;Address:S;PhoneNumber:N;BloodGroup:S;DOB:D" f i=1:1:$l(cols,";") { s c=$p(cols,";",i) d mgr.ColumnNames.Insert($p(c,":",1)) d mgr.ColumnTypes.Insert($p(c,":",2)) } d mgr.Export() } }
go to post Vitaliy Serdtsev · Mar 11, 2019 Hi Robert. Exactly. Programmatically Managing Roles: This command can only be invoked either from a routine that is part of the CACHESYS database or if the current privileges held include Write permission for the CACHESYS database (%DB_CACHESYS:W). Note that setting $ROLES only alters a process’s added roles, not its login roles. There is a third way, but I specifically did not publish it.
go to post Vitaliy Serdtsev · Mar 11, 2019 Below are two ways without additional permissions on %DB_CACHESYS: #include %systemInclude n try{ s sslName="Test" w "1) GetSSLConfigList^%SYS.SECURITY1(.SSLConfigs)",!! w $$Test1(sslName) w !!,"2) $$ListSSLConfigs^%SYS.SECURITY(Client/Server)",!! w $$Test2(sslName) }catch(ex){ w "Error ", ex.DisplayString(),! } Test1(ssl) { d GetSSLConfigList^%SYS.SECURITY1(.SSLConfigs) f i=1:1:SSLConfigs return:SSLConfigs(i)=ssl $$$YES q $$$NO } Test2(ssl) { q ''$lf($lfs($$ListSSLConfigs^%SYS.SECURITY("Client")_","_ $$ListSSLConfigs^%SYS.SECURITY("Server")) ,ssl) }
go to post Vitaliy Serdtsev · Mar 6, 2019 And if so? CREATE TABLE test ( identifier VARCHAR(200) NOT NULL, value INTEGER COMPUTEONCHANGE("%%UPDATE") COMPUTECODE {&sql(select max(value)+1 into :{*} from test where identifier=:{identifier})}, PRIMARY KEY (identifier) )