DEFQUERY object


Usage:

OBJECT x = CREATE "dynamic", "query"

If an application wishes to use the DEFQUERY object then it should load it once and keep it loaded. Loading it each time it is used is very inefficient.

The writeToString method as implemented in KCML 6.20 has a memory leak. See the notes on the method on how to avoid it.


Query
Table

Query

DEFQUERY object

Defines how the SQL to process a DEFQUERY is generated.
MethodReturnsPurpose
Advance()intAdvance the result set cursor
BindParam(nParam, arg, ...)intBind a parameter
BindRawParam(nParam, arg)intBind a binary parameter
Execute(args, ...)intExecute a prepared query
Prepare()intPrepare SQL for a query
Table(nTable)TableTable object in query (counted from 1)
TableByHandle(hHand)TableReturn first table corresponding to handle hHand
PropertyTypeReturnsPurpose
MaxRowsRWintSets/gets the number of rows allowed in the result set
NumColsRintReturns the number of columns in the result set
NumTablesRintReturns the number of tables in query
RowCountRintReturns the number of rows fetched from the DB
comment$RWstringSets or gets the query identifier
emulationRWBOOLEnables or disables KDB call emulation
forcealiasRWBOOLEnables or disables forcing column names to use the table alias's. By default DEFQUERY will only use a table alias if that table appears more than once. If this is set to true is will always use the table alias when listing columns
hint$RWstringSets or gets the SQL hint
lasterr$RstringReturns the last DB error text
orderby$RWstringAdds 'order by' to the query. Overrides all other 'order by' settings
prefetchRWintsets number of rows to prefetch for query
sql$RstringReturns the SQL for the query
strictRWBOOLEnables or disables strict mode
where$RWstringAdds an auxilliary WHERE clause to the query

Table

Table or view object within a query object

Defines a table or view component of an SQL query.
MethodReturnsPurpose
Fetch(BYREF row$)intFetch next row
GetRow(BYREF row$)intFetch current row in table
GetRowid(BYREF rowid$)intFetch current rowid for table
SetHandle(handle)voidSet database handle for table
PropertyTypeReturnsPurpose
FetchCountRintGet fetched row count for table
HandleRintGet database handle
ReadCountRintGet read count for table
Rowid$RstringReturn ROWID of current row in table. Obsolete, use the GetRowid() method.
join$RWstringGet or Set the join clause on a table