InterSystems IRIS Data Platform 2019.2  /  InterSystems SQL Reference  /  SQL Functions

InterSystems SQL Reference
Previous section           Next section
InterSystems: The power behind what matters   

A scalar function that opens a stream object and returns the corresponding oref.
stream An expression that is the name of a stream field.
%OBJECT is used to open a stream object and return the oref (object reference) of the stream field.
A SELECT on a stream field returns the fully formed oid (object ID) value of the stream field. A SELECT %OBJECT on a stream field returns the oref (object reference) of the stream field. This is shown in the following example, in which Notes and Picture are both stream fields:
  SET myquery = "SELECT TOP 3 Title,Notes,%OBJECT(Picture) AS Photo FROM Sample.Employee"
  SET tStatement = ##class(%SQL.Statement).%New()
  SET qStatus = tStatement.%Prepare(myquery)
    IF qStatus'=1 {WRITE "%Prepare failed:" DO $System.Status.DisplayError(qStatus) QUIT}
  SET rset = tStatement.%Execute()
  WHILE rset.%Next() {
     WRITE "String field: ",rset.Title,!
     WRITE "Stream field oid: ",rset.Notes,!
     WRITE "Stream field oref: ",rset.Photo,!!
  WRITE !,"End of data"
If stream is not a stream field, %OBJECT generates an SQLCODE -128 error.
%OBJECT can be used as an argument to the following functions:
You can perform the same operation by issuing a SELECT on a stream field, then opening the stream oid by calling the $Stream.Object.%Open() class method, which generates an oref from the oid:
SET oref = ##class(%Stream.Object).%Open(oid)
For information on orefs, see “OREF Basics” in Defining and Using Classes. For information on oids, see “Identifiers for Saved Objects: ID and OID” in the same book.
See Also

Previous section           Next section
Send us comments on this page
View this book as PDF   |  Download all PDFs
Copyright © 1997-2019 InterSystems Corporation, Cambridge, MA
Content Date/Time: 2019-09-18 05:38:13