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.
DEFQUERY object
Defines how the SQL to process a DEFQUERY is generated.| Method | Returns | Purpose |
|---|---|---|
| Advance() | int | Advance the result set cursor |
| BindParam(nParam, arg, ...) | int | Bind a parameter |
| BindRawParam(nParam, arg) | int | Bind a binary parameter |
| Execute(args, ...) | int | Execute a prepared query |
| Prepare() | int | Prepare SQL for a query |
| Table(nTable) | Table | Table object in query (counted from 1) |
| TableByHandle(hHand) | Table | Return first table corresponding to handle hHand |
| Property | Type | Returns | Purpose |
|---|---|---|---|
| MaxRows | RW | int | Sets/gets the number of rows allowed in the result set |
| NumCols | R | int | Returns the number of columns in the result set |
| NumTables | R | int | Returns the number of tables in query |
| RowCount | R | int | Returns the number of rows fetched from the DB |
| comment$ | RW | string | Sets or gets the query identifier |
| emulation | RW | BOOL | Enables or disables KDB call emulation |
| forcealias | RW | BOOL | Enables 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$ | RW | string | Sets or gets the SQL hint |
| lasterr$ | R | string | Returns the last DB error text |
| orderby$ | RW | string | Adds 'order by' to the query. Overrides all other 'order by' settings |
| prefetch | RW | int | sets number of rows to prefetch for query |
| sql$ | R | string | Returns the SQL for the query |
| strict | RW | BOOL | Enables or disables strict mode |
| where$ | RW | string | Adds an auxilliary WHERE clause to the query |
Table or view object within a query object
Defines a table or view component of an SQL query.| Method | Returns | Purpose |
|---|---|---|
| Fetch(BYREF row$) | int | Fetch next row |
| GetRow(BYREF row$) | int | Fetch current row in table |
| GetRowid(BYREF rowid$) | int | Fetch current rowid for table |
| SetHandle(handle) | void | Set database handle for table |
| Property | Type | Returns | Purpose |
|---|---|---|---|
| FetchCount | R | int | Get fetched row count for table |
| Handle | R | int | Get database handle |
| ReadCount | R | int | Get read count for table |
| Rowid$ | R | string | Return ROWID of current row in table. Obsolete, use the GetRowid() method. |
| join$ | RW | string | Get or Set the join clause on a table |