Hi Timothy,

very nice article, I think that regarding restoring of the current device:

Set $io = tDevice

  The proper way to set the current device ($io) is issuing the Use command:

Use tDevice

  From the doc:

You issue a USE command to change the current device.
.....

This special variable cannot be modified using the SET command. Attempting to do so results in a <SYNTAX> error.

https://cedocs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?K...

Enrico

I think the most efficient way to test if a column exists in the result set is using the columnIndex property of the metadata (instance of %SQL.StatementMetadata):

SAMPLES>Set rs=##class(%SQL.Statement).%ExecDirect(.st,"select name,age from Sample.Person")
SAMPLES>Write rs.%Next()
1
SAMPLES>Set rsmd = rs.%GetMetadata()
SAMPLES>If $data(rsmd.columnIndex("NAME")) Write rs.Name
Xiang,Gertrude X.
SAMPLES>If $data(rsmd.columnIndex("NOTEXISTENT")) Write ""

Enrico