go to post Javier Llobet · Jul 8, 2020 I don't know if i will prefer override the %JSONExportToString and %JSONExportToStream or wrapping but that dirty trick.. Class test.elementList Extends (%ListOfObjects, %JSON.Adaptor) { /// The type (class name) of the elements stored in the collection. Parameter ELEMENTTYPE = "test.element"; /// Returns this object as a JSON Stream Method %JSONExportToStream(ByRef objStream As %Stream.Object, %mappingName As %String = "") As %Status { #Dim objStream As %Stream.TmpCharacter = ##class(%Stream.TmpCharacter).%New() Do objStream.Write("[") For i=1:1:..Size { Do ..GetAt(i).%JSONExportToStream(.objStream, %mappingName) If (i<..Size) { Do objStream.Write(",") } } Do objStream.Write("]") Return $$$OK } /// Returns this object as a JSON string Method %JSONExportToString(ByRef jsn As %String, %mappingName As %String = "") As %Status { #Dim jsonElement As %String = "" Set jsn = "[" For i=1:1:..Size { Set jsonElement = "" Do ..GetAt(i).%JSONExportToString(.jsonElement, %mappingName) Set jsn = jsn_jsonElement If (i<..Size) { Set jsn = jsn_"," } } Set jsn = jsn_"]" Return $$$OK } }
go to post Javier Llobet · Jul 8, 2020 Hello, First of all, great job for this backport ! I was trying it and i found a kind of an issue regarding to export and object to json that is an inheritance of %ListOfObjectsIf we have a list of elementtype of and object and then we try to export this to a json we get this json instead of a correct json. exported json: { "ElementType":"test.element", "Size":"1"} Json that we want: [ { "field1":"testField1", "field2":"testField2" }] Test classes: Class test.elementList Extends (%ListOfObjects, %ZJSON.Adaptor) { /// The type (class name) of the elements stored in the collection. Parameter ELEMENTTYPE = "test.element"; } Class test.element Extends (%RegisteredObject, %ZJSON.Adaptor) { Property field1 As %String [ InitialExpression = "testField1" ]; Property field2 As %String [ InitialExpression = "testField2" ]; } Class test.Main Extends %RegisteredObject { ClassMethod Run() { Set elem = ##class(test.element).%New() Set elemList = ##class(test.elementList).%New() Do elemList.Insert(elem) Do elemList.%JSONExportToString(.json) Do ##class(%ZJSON.Formatter).%New().Format(json) } } I try it in IRIS and i got the same problem.
go to post Javier Llobet · Jun 12, 2019 Im executing inside a sql procedure the next sentence: Set columnLength = "" &SQL(SELECT character_maximum_length INTO :columnLength FROM information_schema.columns WHERE table_name = 'MYTABLE' AND column_name = 'MYCOLUMN' AND table_schema = 'MYSCHEMA') If ((SQLCODE = 0) && (columnLength '= 32000)) { &SQL(ALTER TABLE MYTABLE ALTER COLUMN MYCOLUMN VARCHAR(32000)) IF ((SQLCODE '= 0) && (SQLCODE '= 100)) { SET %sqlcontext.%SQLCODE = SQLCODE SET %sqlcontext.%Message=%msg Quit } } And im getting the error: %msg: <Insufficient Privilege For Operation at location: DDL ALTER TABLE Modify Column Datatype>] And i try with NO Data and the same error. I added a %All rol to my user connected and then it's possible to alter the table. So i need one permission or priviledge that im missing....
go to post Javier Llobet · Jun 11, 2019 the result is true for this command, so i have access but doesnt work.