Hi @Evgeny Shvarov
I created a mix from #1 and #2 without global mapping.
Temporary tables are excellent for this challenge
as they drop at the end of the process. No clean-up needed !
It's kind of a Snapshot
- Log in to post comments
Hi @Evgeny Shvarov
I created a mix from #1 and #2 without global mapping.
Temporary tables are excellent for this challenge
as they drop at the end of the process. No clean-up needed !
It's kind of a Snapshot
A totally different approach, excluding JSON, pure SQL
I use the same query for my small code example
SELECT TOP 5 ssn, home_state,name from Sample.employee
USER>
USER>ZN "SAMPLES"
SAMPLES>:sql
SQL Command Line Shell
-----------------------------
[SQL]SAMPLES>> << entering multiline statement
1>>CREATE GLOBAL TEMPORARY TABLE %ZZ.resultset as
2>>SELECT TOP 5 ssn, home_state,name from Sample.employee
3>>go
17. CREATE GLOBAL TEMPORARY TABLE %ZZ.resultset as
SELECT TOP 5 ssn, home_state,name from Sample.employee
5 Rows Affected
[SQL]SAMPLES>>quit
SAMPLES>zn "USER"
USER>:sql
SQL Command Line Shell
-----------------------------
[SQL]USER>>SELECT * from %ZZ.resultset
18. SELECT * from %ZZ.resultset
| SSN | Home_State | Name |
| -- | -- | -- |
| 217-28-9642 | NC | Emerson,Xavier O. |
| 226-71-5540 | CO | Malkovich,Bob V. |
| 396-77-7486 | UT | Joyce,Juanita V. |
| 558-18-5848 | IA | Ingleman,Josephine Q. |
| 943-90-5082 | TN | Page,Valery R. |
5 Rows(s) AffectedNow it's all in your handsEventually run DROP TABLE %ZZ.resultsetbefore next use with different columns.Or just use different temp table for repeated use with other SELECT
Once upon a time, there was no JSON support!
But your challenge could be resolved by these steps:
A simplified example:
USER>ZN "SAMPLES"
SAMPLES>set sql="SELECT top 5 name, ssn from sample.employee"
SAMPLES>set sta=##class(%SQL.Statement).%New()
SAMPLES>write sta.%Prepare(.sql)
1
SAMPLES>set res=sta.%Execute()
SAMPLES>kill ^SPOOL($j)
SAMPLES>open 2:$JOB
SAMPLES>use 2 do res.%Display()
SAMPLES>close 2
SAMPLES>ZN "USER"
USER>Zwrite ^|"SAMPLES"|SPOOL($JOB)
^|"SAMPLES"|SPOOL(13488,1)="Name"_$c(9)_"SSN"_$c(13,10)
^|"SAMPLES"|SPOOL(13488,2)="Emerson,Xavier O."_$c(9)_"217-28-9642"_$c(13,10)
^|"SAMPLES"|SPOOL(13488,3)="Malkovich,Bob V."_$c(9)_"226-71-5540"_$c(13,10)
^|"SAMPLES"|SPOOL(13488,4)="Joyce,Juanita V."_$c(9)_"396-77-7486"_$c(13,10)
^|"SAMPLES"|SPOOL(13488,5)="Ingleman,Josephine Q."_$c(9)_"558-18-5848"_$c(13,10)
^|"SAMPLES"|SPOOL(13488,6)="Page,Valery R."_$c(9)_"943-90-5082"_$c(13,10)
^|"SAMPLES"|SPOOL(13488,7)=$c(13,10)
^|"SAMPLES"|SPOOL(13488,8)="5 Rows(s) Affected"
^|"SAMPLES"|SPOOL(13488,2147483647)="{67640,77930{9{"
USER> The content here is:
Name SSN
Emerson,Xavier O. 217-28-9642
Malkovich,Bob V. 226-71-5540
Joyce,Juanita V. 396-77-7486
Ingleman,Josephine Q. 558-18-5848
Page,Valery R. 943-90-5082
5 Rows(s) Affected
Now you can loop over your result as on any other Global
as you need
From your initial question, I understood that you have SQL access over ODBC
so this article might show a workaround: Get your code over ODBC/JDBC
You are free to formulate whatever you want to achieve.
same situation for Caché and IRIS
inside the classmethod it is all standard COS/ISOS
similar;
Of course: Working with Globals requires experience in COS/ISOS
ClassMethods can be projected to SQL as Procedures.
That's what I used in the only class (ISOS.cls) of this package
The package was written for IRIS but worked in Caché as well for ages..
Way back in 2020 I wrote an example of how to run COS over ODBC/JDBC
Works of course for any ^Global manipulations
ObjectScript-Over-ODBC-
In OEX there are 2 examples to create a persistent (or temporary) class from JSON
Launching a related query to get a ResultSet is just a standard exercise then.
READY 2026 is the place to find your ultimate answers on IRIS.
in variation of Frank Sinatra:

so this acts in some way similar to #(variable + formula)# syntax
that we know from &html<..> or &js< ..> blocks for CSP
??
first you may try to run your query in your code for a few records
to see by what format EFFDT is returned internally
a quick check from the hip.
.... within the Management Portal I get results .....
>> SMP knows 3 modes: Display (3/2/2026) - Logical (+$h 67631) - ODBC (2026-03-02)
>> Which one is working for you ?
I'd guess WHERE EFFDT > :pDate is the critical point
If the formatting doesn't match, it may cause strange results.
??
set daysBack=-1*daysBack
&sql(SELECT DATEADD('day', :daysBack, CURRENT_DATE) INTO :tDate)or (didn't try)
&sql(SELECT DATEADD('day', (-1)*:daysBack, CURRENT_DATE) INTO :tDate)As my 5* review in OEX is still blocked after fixing
a minor typo in text I'lll publish it here.
-----------------------------------------------------------------------

method jsonstring() is missing a return value
suggestion
ClassMethod jsonstring(id, map = "") As %String [ SqlProc ]
The rest is working perfectly
The use of customized mapping was new to me
Excellent improvement and very useful
Expect my review on OEX
The idea of
set ^A($char(65535)) = ""Looks good at first sight, but this might be the next follower
set ^A($char(65535),0) = ""a great community! 🥳
sorry, I'm no expert on those subjects
Just great !
and an incredible consumption of resources on disk and cpu
with my Windows Docker Desktop
😎
list display failed at that point also text was scrambled
now it's working normal again
¿Dónde está la lista?
? no list added ?
So it's clear.
Old_Class loads old defined properties in a local Object structure
and writes only this structure back.
It has no idea of New properties and doesn't write it.
Just a guess:
$LB(...) in ^GlobalD of Old_class is shorter than for New_class
So %Save() of Old_class is a data killer.
OK,
but prerequisit is, that both definitions are identical.
Especially in the Storage definition, where properties are mapped to globals
a selphy ?? 😉
ATTENTION ! This made me nervous.
In essence, the two classes are sharing the same data / Index / stream globals.
This means there is also
Parameter MANAGEDEXTENT As INTEGER = 0;
Otherwise, it wouldn't compile
Re-reading your question, I understand that properties in
New_class are not identical and synchronized with Old_class ?
So even Storage Definition might be different ?
IF YES, I'd say it's highly risky!
Big Thanks for this recognition !
Especially for the team that made it possible.
Does it work without that UnitTest line in the Dockerfiles ??
([ $TESTS -eq 0 ] || iris session iris -U $NAMESPACE "##class(%ZPM.PackageManager).Shell(\"test $MODULE -v -only\",1,1)") && \
Running UnitTest directly in iris.script might be easier to control.
Checking UnitTests with ZPM manually after the first install might give more precise info of the problem