A totally different approach, excluding JSON, pure SQL
- create temporary table
- Insert your result
- consume it within the same process
- eventually drop the table definition for a different query
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
- Log in to post comments

