go to post Alexander Koblov · Jul 15, 2016 Hi Raghu. I don't know about XPath, but maybe using XSLT might help you here: Class Sample.XSLTransform [ Abstract ] { ClassMethod test() { set tXML= ##class(%GlobalCharacterStream).%New() do tXML.Write("<HHSOS><DIAGNOSES><DIAGNOSIS_DATA><DIAGNOSIS_DATA_GUID>3762875</DIAGNOSIS_DATA_GUID><DIAGNOSIS_DATA_GUID>37628752</DIAGNOSIS_DATA_GUID></DIAGNOSIS_DATA><DIAGNOSIS_DATA></DIAGNOSIS_DATA><DIAGNOSIS_DATA></DIAGNOSIS_DATA><DIAGNOSIS_DATA_GUID>37628753</DIAGNOSIS_DATA_GUID></DIAGNOSES></HHSOS>") set tXSL=##class(%Dictionary.CompiledXData).%OpenId(..%ClassName(1)_"||ExampleXSL").Data set tSC=##class(%XML.XSLT.Transformer).TransformStream(tXML,tXSL,.tOutput) zwrite tSC set tSC=tOutput.OutputToDevice() } XData ExampleXSL { <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:template match="/"> <xsl:copy-of select="//DIAGNOSIS_DATA_GUID[1]"/> </xsl:template> </xsl:stylesheet> } } SAMPLES>d ##class(Sample.XSLTransform).test() tSC=1 <?xml version="1.0" encoding="UTF-8"?><DIAGNOSIS_DATA_GUID>3762875</DIAGNOSIS_DATA_GUID><DIAGNOSIS_DATA_GUID>37628753</DIAGNOSIS_DATA_GUID>
go to post Alexander Koblov · Jul 12, 2016 Conrad, your question have two parts a) For queries like WHERE a = (select ...) if subquery returns more than one row, Caché will compare left part with first value of subquery. b) If several people are tied for the minimum age, then following query prints all of them SELECT Age,Name,home_state FROM Sample.Person p1 WHERE age = ( SELECT min(age) FROM Sample.Person p2 WHERE p1.home_state = p2.home_state)
go to post Alexander Koblov · Jul 12, 2016 Hi Cheng Cheng. This doc lists all intrinsic properties: http://docs.intersystems.com/cache20161/csp/docbook/DocBook.UI.Page.cls?...
go to post Alexander Koblov · Jul 12, 2016 Documentation explains both functions well and with examples, so I encourage you to look into them. Especially first two examples for %ALL function ALLMEMBERS -- function that returns a set of all members of the given level or hierarchy http://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=... %ALL -- function that enables you to use a member while ignoring any ROW and COLUMN context that uses the hierarchy to which this member belongs. http://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=... As to your question about calculating percentage of the top level, here is sample that for each product calculates revenue percentage of total from all products (2nd column) and from category for this product (3rd column). RevenuePctOfAllProducts and RevenuePctOfParent are calculated measures that defined as follows: RevenuePctOfAllProducts: Measures.[Amount Sold] / SUM(Product.[All Product].%ALL, Measures.[Amount Sold]) RevenuePctOfParent: Measures.[Amount Sold] / SUM(Product.CurrentMember.Parent, Measures.[Amount Sold]) So the full query looks like: WITH MEMBER [MEASURES].[RevenuePctOfAllProducts] AS 'Measures.[Amount Sold] / SUM(Product.[All Product].%ALL, Measures.[Amount Sold])' MEMBER [MEASURES].[RevenuePctOfParent] AS 'Measures.[Amount Sold] / SUM(Product.CurrentMember.Parent, Measures.[Amount Sold])' SELECT NON EMPTY {[Measures].[Amount Sold], [MEASURES].[REVENUEPCTOFALLPRODUCTS], [MEASURES].[REVENUEPCTOFPARENT]} ON 0, NON EMPTY HEAD(NONEMPTYCROSSJOIN([Product].[P1].[Product Category].Members,[Product].[P1].[Product Name].Members),2000) ON 1 FROM [HOLEFOODS]
go to post Alexander Koblov · Jul 11, 2016 As far as I understand such usage of GROUP BY and select columns is not standard in SQL world. That is -- if we GROUP BY some fields, then in SELECT list we can have either fields we group by or other fields as arguments of aggregate functions. We can write SELECT home_state, max(age) FROM sample.person GROUP BY home_state But we cannot write SELECT home_state, max(age), name FROM sample.person GROUP BY home_state It is not clear -- what name out of all rows that have the same home_state do we want. Consider following data in Sample.Person: Age Name Home_State 10 John MA 10 Jim MA What name will following query return John or Jim? SELECT Age,Name FROM Sample.Person GROUP BY Home_State HAVING Age = MIN(Age) I prefer following variant of the query with join: SELECT Age,Name,home_state FROM Sample.Person p1 WHERE age = ( SELECT min(age) FROM Sample.Person p2 WHERE p1.home_state = p2.home_state) That returns both rows from the sample data above.
go to post Alexander Koblov · Jul 6, 2016 I wonder if this extra line is caused by the line break between </script> and the xml header. Can you try to move <?xml version="1.0" encoding="UTF-8" ?> Before <script> ?
go to post Alexander Koblov · Jul 1, 2016 Hi Cheng Cheng. %DeepSee.ResultSet has property %UseCache to make query not to use cache. You can set it if you run using %DeepSee.ResultSet directly. As far as I know this is not configurable from Analyzer or User Portal. And it cannot be set system- wide or for particular cube. Regards, Alexander.
go to post Alexander Koblov · Jun 30, 2016 Hi Javier. If you use ExecuteQueryParmArray then I think you should also Set par = 1 If you use ExecuteQuery then you should call it like Set tSC = ..Adapter.ExecuteQuery(.QueryResultSet,sql,par) http://docs.intersystems.com/ens201513/csp/docbook/DocBook.UI.Page.cls?K...
go to post Alexander Koblov · Jun 29, 2016 Also please notice that Base64Encode does not work with Unicode characters: http://docs.intersystems.com/cache20152/csp/documatic/%25CSP.Documatic.c...
go to post Alexander Koblov · Jun 28, 2016 Attila, can you please elaborate on why it is potentially dangerous to refer to data outside of current record unless Calculated is specified? I personally use Calculated only when property value might change during oref lifetime. If property value is not changed once object is in process memory, then there is no need for Calculated, as I understand -- Transient is enough.
go to post Alexander Koblov · Jun 23, 2016 I usually create new empty DB, then ^GBLOCKCOPY globals from old DB. And then replace old DB with the new one.
go to post Alexander Koblov · Jun 22, 2016 Yes, Illegal CSP Request usually means that access to this particular class is prohibited. If your web application named '/csp/healthshare/mhclib/' then you need to enable classes as follows: set ^SYS("Security","CSP","AllowClass","/csp/healthshare/mhclib/","%SOAP.WebServiceInfo")=1 set ^SYS("Security","CSP","AllowClass","/csp/healthshare/mhclib/","%SOAP.WebServiceInvoke")=1 Notice that calling SOAP Service via test webpage (%SOAP.WebServiceInvoke.cls) is independent from calling web service via SOAP protocol. For that you should check option "Inbound Web Services" in Web application settings. %SOAP.WebServiceInfo and %SOAP.WebServiceInvoke are just pages to test web services via Browser. SOAP protocol itself does not use these pages.
go to post Alexander Koblov · Jun 22, 2016 Message "An error occurred with the CSP application and has been logged to system error log (^ERRORS)" means that you can check error in Management Portal -> System Operation -> System Logs -> Application Error Log -> [Namespace] Or for debugging purposes set error page for web application to %CSP.Error.cls http://docs.intersystems.com/cache20161/csp/docbook/DocBook.UI.Page.cls?... and see errors on the page itself
go to post Alexander Koblov · Jun 21, 2016 You can create one post that is just an index and reference this post in each new material. Then just update this index post once after each new posting
go to post Alexander Koblov · Jun 13, 2016 Hi Randy. FILTER option in SETTINGS references "Allowed Default Values for Filters" section of doc http://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=... You can specify set of members as follows: "{&[keyval1],&[keyval2],&[keyval3]}" Then you need to URL encode this value: http://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=... Particularly by replacing & with %26 and , with %2C For example, if I want to pass to "Basic Dashboard Demo" several values for Home Zip Code filter I need to create following string: &SETTINGS=FILTER:[HomeD].[H1].[ZIP].{&[32006],&[32007]} And then URL encode it to &SETTINGS=FILTER:[HomeD].[H1].[ZIP].{%26[32006]%2C%26[32007]}
go to post Alexander Koblov · Jun 8, 2016 Hi Blaise. Does following query looks like what you need? With Member Measures.[RunningTotal] As 'AGGREGATE(%TIMERANGE(DateOfSale.[Actual].[MonthSold].&[201101],DateOfSale.CurrentMember), MEASURES.[Amount Sold])',FORMAT_STRING='$#,#.#' SELECT {Measures.[Amount Sold],Measures.[RunningTotal]} ON 0, [DateOfSale].[Actual].YearSold.&[2016].CHILDREN ON 1 FROM HOLEFOODS It prints two columns -- Revenue in current month and Total revenue from 2011-01 up to current month. Rows are months of 2016 year.