go to post Vitaliy Serdtsev · Sep 15, 2021 Did you look in the direction of %Stream.GlobalCharacterSearchable? See also Scalar Functions and Streams SELECT Notes Stream,DATALENGTH(Notes) lenStream,SUBSTRING(Notes,DATALENGTH(Notes)-9) AS StreamLast10Chars FROM Sample.Employee WHERE Notes IS NOT NULL
go to post Vitaliy Serdtsev · Sep 15, 2021 Simple sample: Class dc.test Extends %ZEN.Component.page { XData Contents [ XMLNamespace = "http://www.intersystems.com/zen" ] { <page xmlns="http://www.intersystems.com/zen"> <tablePane id="tp" sql="select 1 ID,'Western branch' Branch,{d '2021-03-15'} "Date",35 Suma union select 2,'Eastern branch',{d '2020-12-11'},37" /> <button caption="Row unselect" onclick="zenPage.rowUnselect()"/> </page> } ClientMethod rowUnselect() [ Language = javascript ] { var tp=zen('tp'); row=tp.selectedIndex; if (tp.rowSelect && row>=0) { var old=tp.enableToggleSelect; tp.enableToggleSelect=true; tp.selectRow(row); tp.enableToggleSelect=old; } } }
go to post Vitaliy Serdtsev · Sep 15, 2021 I also will insert my five kopecks. The %Library package also includes stream classes, but those are deprecated. The class library includes additional stream classes, but those are not intended for general use. Working with Streams I have %Stream.FileCharacter was an order of magnitude faster than %[Library.]File If you rewrite the line-by-line reading to read blocks with further parsing of lines, the speed will more increase by an order of magnitude. Sample Class dc.test [ Abstract ] { ClassMethod ReadCSVStream(fCSV As %String) As %String { s stream = ##class(%Stream.FileCharacter).%New() d stream.LinkToFile(fCSV) s time1=$zh While 'stream.AtEnd { s line=stream.ReadLine($$$MaxLocalLength) } s diff=$zh-time1 q diff } ClassMethod ReadCSVStreamBlock(fCSV As %String) As %String { s stream = ##class(%Stream.FileCharacter).%New() d stream.LinkToFile(fCSV) s i=0,time1=$zh While 'stream.AtEnd { s chunks($i(i))=stream.Read($$$MaxLocalLength) // do parsing chunk to lines } s diff=$zh-time1 q diff } ClassMethod ReadCSVOURC(fCSV As %String) As %String { o fCSV::1 e q "Missing File" s eof=$zu(68,40,1) u fCSV s time1=$zh f { r line q:$zeof // do something with line } s diff=$zh-time1 c fCSV d $zu(68,40,eof) q diff } /// d ##class(dc.test).Test() ClassMethod Test() { s ptr=0, clnm=$classname() &sql(select %dlist(Name) into :list from %Dictionary.CompiledMethod where Parent=:clnm and Name %startswith 'ReadCSV' group by Parent order by SequenceNumber) while $listnext(list,ptr,m) { w !,"[",m,"]",?20,"execution: ",$classmethod(clnm,m,"data.csv"),! } } } On the Internet, you can find a lot of materials about comparing the speed of reading files (in particular CSV) for different programming languages (Python, C/C++, R, C#, Java, etc.), for example (this is machine translation). Often, those who make such comparisons do not always know all these languages equally well, so sometimes casus happen. Who do you think in the article above was faster when reading 1e7+ lines: Fortran or C++ ? Fortran :) If we approach the issue formally, then the advantage will be given to compiled languages, not interpreted ones, as well as the implementation that uses all the capabilities of the operating system and hardware.
go to post Vitaliy Serdtsev · Sep 14, 2021 Example of using the import/export classes SQL Export Data with %SQL.ExportMgr
go to post Vitaliy Serdtsev · Sep 6, 2021 Caché SQL Optimization Guide New Video: Optimizing SQL Queries New Video: Optimizing Your SQL Queries SQL Performance Resources I think that's enough for a start ;)
go to post Vitaliy Serdtsev · Sep 6, 2021 Here you will find a lot of useful things in particular $QLENGTH: Using Globals
go to post Vitaliy Serdtsev · Aug 20, 2021 See Base64EncodeStream Or %Atelier.v1.Utils.General:Base64FromStream()
go to post Vitaliy Serdtsev · Aug 20, 2021 See documentation: $ZF(-100) requires the %System_Callout:U privilege. And check "Error Handling".
go to post Vitaliy Serdtsev · Aug 20, 2021 See documentation: Frequently Asked Questions About CSP: How do I debug a CSP page?
go to post Vitaliy Serdtsev · Aug 20, 2021 Why not use numeric codes? $ascii("á") = 225 set s1=$zconvert("Flávio","I","HTML"), s2=$zconvert("Flávio","I","HTML") write s1,$select(s1=s2:" = ",1:" <> "),s2
go to post Vitaliy Serdtsev · Aug 17, 2021 Don't pay attention, someone very needs an Apple iPad. I found a very interesting article about a very ancient language, but it's not Mumps : Banks scramble to fix old systems as IT 'cowboys' ride into sunset
go to post Vitaliy Serdtsev · Apr 30, 2021 How do you count "Count"? Why is "Northwest" 1 instead of 2 for 2021? For now so: select v.Branch, nvl(sum(c %FOREACH(v.Branch)),0) "Count" from ( select 'Northwest' Branch,$listbuild('Northern','Western') Branches union select 'Oriental',$listbuild('Eastern') union select 'Southern',$listbuild('Southern') ) v left join (select replace(%exact(Branch),' branch','') Branch,count(* %FOREACH(Branch)) c from yourtable where year("Date")=2021 group by Branch) m on m.Branch %inlist v.Branches group by v.Branch
go to post Vitaliy Serdtsev · Apr 29, 2021 Can you provide a small sample table with the data and the result you want to get?
go to post Vitaliy Serdtsev · Apr 29, 2021 You are implicitly using %Library.SqlQuery:Func() method, in which, as @Robert Cemper rightly pointed out, $get() is used. You can do it differently: Query GetInfo(pObject AS Kurro.MyClass) As %SQLQuery(CONTAINID = 1, ROWSPEC = "IdList:%String,IdProcess:%String,Duration:%String") [ SqlProc ] { SELECT IdList, IdProcess, Duration FROM Kurro.MyClass WHERE KeyProcess = :pObject.KeyProcess AND CodeSpecialist = :pObject.CodeSpecialist AND CodeProvider = :pObject.CodeProvider AND CodeCenter = :pObject.CodeCenter AND "Date" = :pObject.Date } set obj=##class(Kurro.MyClass).%New() set obj.KeyProcess="1033004-1#" set obj.CodeSpecialist = "surgery" set obj.CodeProvider = "PR002" set obj.CodeCenter = "CENTER-01" set obj.Date = $ZDATETIME($ZDATETIMEH("2021-04-30 15:45:00",3,1),3,1) set st=##class(%SQL.Statement).%New() set sc=st.%PrepareClassQuery("Kurro.MyClass","GetInfo") if $$$ISERR(sc) {write "%PrepareClassQuery failed:" do $System.Status.DisplayError(sc) quit} set result=st.%Execute(obj) do result.%Display()
go to post Vitaliy Serdtsev · Apr 29, 2021 I don't quite understand what you want to get. If in the forehead, then so: Select v.valueId, m.name From (Select 1 valueId Union Select 2 Union Select 3 Union Select 4 Union Select 5) v left Join otherTable m on m.id = v.valueIdBut you can achieve the same thing more easily through IN or %INLIST.