· Jul 20, 2020 2m read

SPOOL as SQL Table

It is a classic Global Mapping exercise presenting ^SPOOL as Class / Table


Device #2 named SPOOL dates back to the predecessors of Caché and IRIS
It was the first "%Stream" like option to buffer output before printing.
It is also the first and till today the most simple way of output redirection.


This is also an example of a mapped Global.
USE 2 redirects the output into the Global ^SPOOL

You can read the global manually or with some ancient utilities
or use this mapping to access it as class or a SQL table.

The structure of Spool

  • the global ^SPOOL is local to your namespace
  • fist subscript is a UNIQUE Document_ID
  • second subscript is a line number UNIQUE to the document.
  • both together form the IDkey

Details: The Spool Device

How to use it:

Open a session in your container

 USER>set file="/irisdev/app/lorem.txt" open file:"RS":1 else  write "no file",! quit
 USER>open 2 for i=1:1 u file read line quit:line=""  use 2 write line,!
 USER>close 2 zwrite ^SPOOL

Now you can see your SPOOLed text either from SMP or directly from your session

USER>do $system.SQL.Shell()
SQL Command Line Shell
The command prefix is currently set to: <<nothing>>.
Enter <command>, 'q' to quit, '?' for help.

ID Document LineNumber Text
1||1 1 1 Lorem ipsum dolor sit amet, consectetuer adipiscing
1||2 1 2 elit, sed diam nonummy nibh euismod tincidunt ut laoreet
1||3 1 3 dolore magna aliquam erat volutpat. Ut wisi enim ad minim
1||4 1 4 veniam, quis nostrud exercitation ulliam corper suscipit lobortis
1||5 1 5 nisl ut aliquip ex ea commodo consequat.
1||6 1 6 Duis autem veleum iriure dolor in hendrerit in vulputate
1||7 1 7 velit esse molestie consequat, vel willum lunombro dolore
1||8 1 8 eu feugiat nulla facilisis
1||9 1 9 at vero eros et accumsan
1||10 1 10 et iusto odio dignissim qui blandit praesent
1||11 1 11 luptatum zzril delenit augue duis dolore te feugait nulla
1||12 1 12 facilisi. Li Europan lingues es membres

12 Rows(s) Affected
statement prepare time(s)/globals/cmds/disk: 0.0732s/37737/175514/0ms
execute time(s)/globals/cmds/disk: 0.0008s/13/1786/0ms
cached query class: %sqlcq.IRISAPP.cls2




Discussion (0)1
Log in or sign up to continue