go to post Vitaliy Serdtsev · Aug 21, 2023 Hi Ashok. Can you tell in more detail what exactly is the problem of not-keeping the trailing zeros: calculations give an incorrect result, an error is generated or something else? USER>set json = { "decimal": (12.000)} zw json json={"decimal":12} ; <DYNAMIC OBJECT> USER>set n=12.000 zw n n=12
go to post Vitaliy Serdtsev · Aug 21, 2023 You can enable SQL Gateway Logging. Also make sure that the necessary JDK/JRE version is installed and configured correctly. For simplicity, I would check the connection outside of IRIS, for example through DbVisualizer/DBeaver/SQuirreL/etc.
go to post Vitaliy Serdtsev · Aug 14, 2023 In this case, it will be easier to temporarily dump the data into globals. Then you can access this data at any time, including through %ScrollableResultSet. Here is a small example: ClassMethod tt() [ Language = tsql, ReturnResultsets, SqlName = mycls, SqlProc ] { drop table if exists mytemp1,mytemp2 select name,dob,spouse into mytemp1 from Sample.Person where name like 'A%' select name,age,home_city,home_state into mytemp2 from Sample.Person where home_state = 'MA' } ClassMethod Test() { d ##class(%SQL.Statement).%ExecDirect(,"call dc.mycls()") d ##class(%SQL.Statement).%ExecDirect(,"select * from mytemp1").%Display() d ##class(%SQL.Statement).%ExecDirect(,"select * from mytemp2").%Display() ; and even so d ##class(%SQL.Statement).%ExecDirect(,"select * from mytemp1 cross join mytemp2").%Display() }
go to post Vitaliy Serdtsev · Aug 11, 2023 You are right, this is a mistake in the documentation. Here is part of my code for IRIS 2023.2: var connection = new OdbcConnection( "DRIVER={InterSystems IRIS ODBC35};SERVER=localhost;PORT=1972;DATABASE=USER;UID=_system;PWD=SYS;Unicode SQLTypes=1;Query Timeout=1");Connection and display of the query result were successful.
go to post Vitaliy Serdtsev · Aug 11, 2023 One of the possible options: ClassMethod odbcTest() As %Integer [ ReturnResultsets, SqlName = PersonSets2, SqlProc ] { #dim %sqlcontext As %ProcedureContext if '$isobject($Get(%sqlcontext)) { set %sqlcontext = ##class(%ProcedureContext).%New() } s tReturn = 0 s conn=##class(%SQLGatewayConnection).%New() s sc=conn.Connect("TEST Samples","_system","SYS") //datasource if $$$ISOK(sc) { d conn.AllocateStatement(.h1) d conn.Prepare(h1,"select name,dob,spouse from sample.person where name %STARTSWITH 'A'") d conn.Execute(h1) d %sqlcontext.AddResultSet(conn.getResultSet(h1)) d conn.AllocateStatement(.h2) d conn.Prepare(h2,"select name,age,home_city,home_state from sample.person where home_state = 'MA'") d conn.Execute(h2) d %sqlcontext.AddResultSet(conn.getResultSet(h2)) s tReturn = 1 }else{ s sqlcode=$system.Status.StatusToSQLCODE(sc,.msg) s %sqlcontext.%SQLCODE = sqlcode, %sqlcontext.%Message = msg } q tReturn }Output: SAMPLES>d ##class(%SQL.Statement).%ExecDirect(,"call Sample.PersonSets2()").%Display() ...Surely there is a way to make it even easier.
go to post Vitaliy Serdtsev · Aug 11, 2023 Maybe you should take a look at the class %ScrollableResultSet?
go to post Vitaliy Serdtsev · Aug 11, 2023 I didn't find in the documentation the line {InterSystems IRIS ODBC35}: ODBC Connection Strings Test Program Try Driver=InterSystems ODBC Driver;...or DRIVER={InterSystems ODBC35};...
go to post Vitaliy Serdtsev · Aug 11, 2023 Try googling "ssl_error_syscall errno 10053". Perhaps some of the suggestions will help you.
go to post Vitaliy Serdtsev · Aug 11, 2023 It's clearer now, this is the tricks of Excel, which convert the string 01022000 to the number 1022000. In your case, try changing the cell type from General to Text. PS: when generating Excel reports, I use the Date cell type (short format DD.MM.YYYY), and from Caché/IRIS I return the %Date type. The components that I use already know how to translate the internal representation of the date 01.02.2000 from the Caché/IRIS format (58105) to Excel (36557) and vice versa.
go to post Vitaliy Serdtsev · Aug 10, 2023 Can I see how you call TO_CHAR? I have a leading zero displayed without problems: SELECT %internal(to_date('01022000','DDMMYYYY')) -- 01022000 -> 58105 ,TO_CHAR(58105,'DDMMYYYY') -- 58105 -> 01022000TO_CHAR: Convert Dates to Formatted Date Strings
go to post Vitaliy Serdtsev · Aug 10, 2023 Try this: Set objcontato=##class(Contatos.Amiguinho).%New() Do objcontato.MoradiaSetObjectId(3) Do objcontato.TrabalhoSetObjectId(2) Set ret=objcontato.%Save()See Fastest Way to Connect Objects
go to post Vitaliy Serdtsev · Aug 4, 2023 size = 52 ClassMethod IsValid(s As %String) As %Boolean { 1 s c=$a(s,$i(i))+1 g:1-$i(z,c=42-(c=41))&c 1 q 'z }
go to post Vitaliy Serdtsev · Aug 3, 2023 You can make it even easier: ClassMethod IsValid(s As %String) As %Boolean [ Language = python ] { import regex;return regex.match("^((?>[^()]|\((?1)\))*)$",s) is not None }Unfortunately, RegExp ICU does not support recursive patterns, otherwise it would be possible to write q $match(s,"^((?>[^()]|\((?1)\))*)$")
go to post Vitaliy Serdtsev · Aug 3, 2023 No. This code will not work in IRIS 2023.1 because changes have been made for security reasons: Improvements to how IRIS classes are generated and called
go to post Vitaliy Serdtsev · Aug 1, 2023 Thanks for the comment. I tested only on the provided data. The second option requires improvement. size = 72 ClassMethod IsValid(s As %String) As %Boolean { q $l(s,"(")=$l(s,")")&($f(s,"(")<$f(s,")"))&($f(s,")(")-$f(s,"()")<2) } size = 69 ClassMethod IsValid(s As %String) As %Boolean { 1 s c=$i(c,$case($e(s,$i(i)),"(":1,")":-1,"":-2,:0)) q:c<0 c=-2 g 1 }
go to post Vitaliy Serdtsev · Aug 1, 2023 size = 61 ClassMethod IsValid(s As %String) As %Boolean { q +##class(%iFind.Utils).TestSearchString($$$URLENCODE(s)) }
go to post Vitaliy Serdtsev · Aug 1, 2023 It's strange, according to approved method of calculating the length of the solution, your code shows a length of 62, not 61. Have you measured the length of your solution using this method?
go to post Vitaliy Serdtsev · Jul 19, 2023 Query FilterBy( Name As %String = "", Age As %Integer = "") As %SQLQuery(CONTAINID = 1, SELECTMODE = "RUNTIME") [ SqlName = SP_Sample_Filter_By, SqlProc ] { SELECT TOP 5 ID, Name, Age, SSN FROM %ALLINDEX Sample.Person WHERE (:Name IS NULL or Name %STARTSWITH :Name) AND (:Age IS NULL or Age >= :Age) }This kind of query ends up preventing Caché SQL compiler from optimizing using index based on each of the criteria made optional. What is your conclusion based on? If you check the plans of this query for different combinations of parameters, then the corresponding indexes are used (it is assumed that the table was previously configured via TuneTable). select * from Sample.SP_Sample_Filter_By('s') SELECT TOP 5 ID, Name, Age, SSN FROM %ALLINDEX Sample.Person WHERE ('s' IS NULL or Name %STARTSWITH 's') AND (NULL IS NULL or Age >= NULL) select * from Sample.SP_Sample_Filter_By(,47) SELECT TOP 5 ID, Name, Age, SSN FROM %ALLINDEX Sample.Person WHERE (NULL IS NULL or Name %STARTSWITH NULL) AND (47 IS NULL or Age >= 47) select * from Sample.SP_Sample_Filter_By('s',47) SELECT TOP 5 ID, Name, Age, SSN FROM %ALLINDEX Sample.Person WHERE ('s' IS NULL or Name %STARTSWITH 's') AND (47 IS NULL or Age >= 47)
go to post Vitaliy Serdtsev · Jul 19, 2023 Did a little test: Class dc.test [ Abstract ] { ClassMethod GetObjectFieldValue( pObject As %DynamicAbstractObject, pField As %String) As %String { quit:pObject="" "" quit:pField="" "" set tResponse="" set tResponse = pObject.%Get(pField) return tResponse } ClassMethod Test() { s p1={ "priority": "2", "lastmodifieduser": "PORTAL", "assignedto": "jdoe01 STAFF", "status": "REVIEW", "documentclass": "PATIENTCASE", "versiontoken": "937486", "departmentid": "999", "patientcaseid": "105555424", "providerusername": "jdoe01", "internalnote": "firstMessage", "subject": "first123", "patientid": 9877654321, "createduser": "PORTAL", "description": "patient case - first123", "documentroute": "MDP", "documentsubclass": "PATIENTCASE_CLINICALQUESTION", "documentsource": "PORTAL", "createddate": "07/17/2023", "lastmodifieddate": "07/17/2023"} s p2="documentsubclass" w ..GetObjectFieldValue(p1,p2) } }Result: USER>d ##class(dc.test).Test() PATIENTCASE_CLINICALQUESTION
go to post Vitaliy Serdtsev · Jul 4, 2023 Your question has already been answered here: Dynamic SQL and Setting SQLCODE