SPOOL to SQL how ?

Primary tabs

Answers

Simply map the ^SPOOL global to a class and get a table %ZZ.SPOOL

like this:

/// Get SQL Access to ^SPOOL
Class %ZZ.SPOOL Extends %Persistent [ Final, SqlRowIdPrivate, StorageStrategy = SpoolSQL ]
{

  Property Document As %Integer [ ReadOnly ];
 
 Property LineNumber As %Integer [ ReadOnly ];
 
Property Text As %String(MAXLEN = "") [ ReadOnly ];
 
Index idx On (Document, LineNumber) [ IdKey ];

Storage SpoolSQL
{

<SQLMap name="Spool">
<Data name="Text">
<Delimiter>$c(13)_$c(10)</Delimiter>
<Piece>1</Piece>
</Data>
<Global>^SPOOL</Global>
<Subscript name="1">
<Expression>{Document}</Expression>
</Subscript>
<Subscript name="2">
<Expression>{LineNumber}</Expression>
</Subscript>
<Type>data</Type>
</SQLMap>
<StreamLocation>^SPOOLS</StreamLocation>
<Type>%Storage.SQL</Type>
} }

 

Any reason why you use

$c(13)_$c(10)

instead of:

$c(13,10)

?

 @ some version in past the code generator struggled with $c(13,10) disliking the  "," for some reason.

Hi,

In Ensemble what would be a real life scenario where we can make use of spooling?

Thanks

every log or similar document that should not see your OS environment is a candidate for SPOOL
eg. sequentially collected by assigning dedicate doc numbers.