DynamicQuery (open)
Dynamic queries object
Syntax
LOADLIB "wh::dbase/dynquery.whlib";
OBJECTTYPE DynamicQuery
Description
This object can be used to construct and execute dynamic queries.
Variables
Functions
- MACRO AddConstraint(STRING _column, STRING type, VARIANT value)
Adds a constraint to the query of the form 'table.column OPERATOR value'. Comparisons will be done case-sensitive.
- MACRO AddDeclaredTable(STRING rename, TABLE tbl, STRING ARRAY select_columns)
Add a new selected table source to the query, with a declared table
- MACRO AddJoin(STRING left_column, STRING type, STRING right_column)
Adds a join to the query of the form 'table.column OPERATOR table.column'. Comparisons will be done case-sensitive.
- MACRO AddRecordArray(STRING rename, RECORD ARRAY vals, STRING ARRAY select_columns)
Add a new selected record array source to the query
- MACRO AddTable(STRING rename, INTEGER transaction, STRING tablename, STRING ARRAY select_columns)
Add a new selected table source to the query
- MACRO AddUppercaseConstraint(STRING _column, STRING type, STRING value)
- MACRO AddUppercaseJoin(STRING left_column, STRING type, STRING right_column)
Adds a join to the query of the form 'table.column OPERATOR table.column'. Comparisons will be done case-insensitive.
- OBJECT FUNCTION Clone()
Clone this query (only valid if it has not been executed yet), creating a new query with the same setup so far
- INTEGER FUNCTION Count()
Executes the the query and returns the number of result rows.
- STRING FUNCTION Dump()
Converts the current query within this object to a select that can be copy-pasted into a Harescript library. This function may not be executed after Execute or Count.
- RECORD ARRAY FUNCTION Execute()
Executes the the query and returns the result rows. These are in the form [ source1 := [ column1 := value, column2 := value, ... ], source2 := ... ].
- MACRO ExecuteForDelete(FUNCTION PTR ondelete)
Executes the the query, calls a callback for every record to delete that record. Call StopExecution() to stop processing within the query.
- MACRO ExecuteForUpdate(FUNCTION PTR onupdate, STRING ARRAY updatecolumns)
Executes the the query, calls a callback for every record to update that record. Call StopExecution() to stop processing within the query.
- MACRO ExecuteTo(MACRO PTR receiver)
Executes the query and send the rows to a specific function. These are in the form [ source1 := [ column1 := value, column2 := value, ... ], source2 := ... ].
- INTEGER FUNCTION GetSourcesLength()
Returns the number of sources that have been added to this query. FIXME: rename to GetSourceCount()
- MACRO RequestAdditionalColumns(STRING rename, STRING ARRAY select_columns)
Adds some columns to the list of columns that must be returned for a source
- MACRO SetLimit(INTEGER xlimit)
Set the maximum number of rows that must be returned. If not called, all records will be returned
- MACRO StopExecution()