Skip to main content

%Library.SQLQuery

Class %Library.SQLQuery Extends %Query [ Not ProcedureBlock, System = 2 ]

For information on this class, see Defining and Using Class Queries.

The %SQLQuery class is used for defining class queries based on SQL definitions.

Parameters

COMPILEMODE

Parameter COMPILEMODE As STRING [ Constraint = "IMMEDIATE,DYNAMIC", Deprecated, Flags = ENUM ] = "IMMEDIATE";

COMPILEMODE parameter deprecated. No longer used.

SQLQUERY;

Parameter SQLQUERY;

SELECTMODE

Parameter SELECTMODE = "RUNTIME";

Methods

Close

ClassMethod Close(%qHandle As %Binary) As %Status [ ProcedureBlock = 1, PublicList = SQLCODE, ServerOnly = 1 ]

Close the query associated with the handle

Func

ClassMethod Func() As %SQL.StatementResult [ CodeMode = generator, ProcedureBlock = 1, ServerOnly = 1 ]

Func is a method that is used to invoke the query as a function, returning an instance of %SQL.StatementResult.

Execute

ClassMethod Execute(ByRef %qHandle As %Binary) As %Status [ CodeMode = generator, ProcedureBlock = 1, ServerOnly = 1 ]

Execute is passed parameters for Query Returns handle for subsequent operations

FetchRows

ClassMethod FetchRows(ByRef %qHandle As %Binary, FetchCount As %Integer = 0, ByRef RowSet As %List, ByRef ReturnCount As %Integer, ByRef AtEnd As %Integer) As %Status [ CodeMode = generator, GenerateAfter = Fetch, PlaceAfter = Execute, ProcedureBlock = 1, ServerOnly = 1 ]

FetchRows returns the next FetchCount rows in the query Updates handle for subsequent operations Returns $list for row or "" if no more rows

Fetch

ClassMethod Fetch(ByRef %qHandle As %Binary, ByRef Row As %List, ByRef AtEnd As %Integer = 0) As %Status [ CodeMode = generator, PlaceAfter = Execute, ProcedureBlock = 1, ServerOnly = 1 ]

Fetch the next row of data from the query.

qHandle is query-defined data and is typically updated by Fetch.

The Fetch method should set Row to be a $List of values corresponding to the columns of the query. If we are past the end of the data and no row is returned, Row should be set to null string (""). If the non-empty row being returned is the last one, AtEnd could be optionally set to 1, indicating that an additional call to Fetch may be avoided.

Row may also be subscripted. If any of the columns in the row are stream orefs then the oref type information is lost in the Row $list encoded value. To retain the oref type, place the oref into Row(columnNumber). %Library.ResultSet recognizes this form and will extract the column value as the subscripted value.

GetInfo

ClassMethod GetInfo(ByRef colinfo As %List, ByRef parminfo As %List, ByRef idinfo As %List, ByRef %qHandle As %Binary, extoption As %Integer = 0, extinfo As %List) As %Status [ CodeMode = generator, ProcedureBlock = 1, ServerOnly = 1 ]

Returns information about the query. It is used by the various ResultSet objects.

SendODBC

ClassMethod SendODBC(ByRef %qHandle As %Binary, ByRef array As %String, qacn As %Integer, ByRef %qrc As %Integer, ByRef piece As %Boolean, ColumnCount As %Integer) [ CodeMode = generator, GenerateAfter = (FetchODBC, Fetch), PlaceAfter = Execute, ProcedureBlock = 1, ServerOnly = 1 ]

Fetch and send a series of rows for the ODBC/JDBC server. For internal use only.