Description

Executes a query method; a query corresponds to a statement handle for a Connection Object.

Syntax

flag = QryMethod (hQry, method, arg1, arg2, arg3, arg4, arg5)

Parameters

The QryMethod function has the following parameters:

ParameterDescription
hQryHandle to the Query.
methodSee methods below.
arg1...arg5Method specific; see methods below.
MethodDescription
QRY_CANCEL$

Cancels an active query.

ValueDescription
HQry [in]Query handle.
QRY_DESTROY$

Releases a Query handle.

ValueDescription
HQry [in]Query handle.

Error returned for an invalid handle or if an error occurred destroying the query.

QRY_EXECUTE$

Executes a query and checks for results.

ValueDescription
hQry [in]Query handle.
arg1 [in]Script
arg2 [in]Execution type (defaults to "standard result set").
arg3 [out]Set to TRUE$ if there are results, FALSE$ otherwise.
QRY_GETERROR$

Retrieves all pending query errors from the DS/XO API.

ValueDescription
hQry [in]Query handle.
arg1 [out]Local error list (@VM-delimited).
arg2 [out]Local severity list.
arg3 [out]Native error list.
arg4 [out]Native severity list.
arg5 [out]Error text list.

Error returned if no errors were pending.

QRY_GETROW$

Retrieves a row from the result set.

ValueDescription
hQry [in]Query handle.
arg1 [out]Result row (@FM-delimited).
arg2 [in]Fetch direction (defaults to FD_FORWARDS$).
arg3 [in]Conversion (defaults to CONV_OI$).
QRY_LISTCOLUMNS$

Creates a result set (as if a script had been executed with QRY_EXECUTE$) of the columns in a database object. The result set contains the columns COLUMN NAME, DATA TYPE, PRECISION, SCALE, NULLABLE, TYPE NAME, LENGTH, RADIX, and REMARKS.

ColumnDescription
COLUMN NAMEThe name of the column.
DATA TYPEThe data type of the column. Data types are defined in the insert DSXO_API and are prefixed with "DS_".
PRECISIONThe column's precision. The precision of a column is its length, if it is a character or binary type, the amount of detail it holds for time and date/time types, or the total number of digits for the decimal type. For date/time, the precision is the number of significant characters in the string "yyyy-mm-dd hh:mm:ss.ffff". For time, the precision is the number of significant characters in the string "hh:mm:ss.ffff".
SCALEThe column's scale. The scale of a column is the number of digits to the right of the decimal point for decimal data types or the number of digits of precision for fractions of a second for time and date/time data types.
NULLABLETrue if the column can contain null values.
TYPE NAMEThe database-specific name of the column's type.
LENGTHThe length used by the database to store the column.
RADIXFor numeric types, the base of the number. Binary numbers are base-2, decimal numbers are base-10.
REMARKS

Miscellaneous information that the database can choose to provide.

ValueDescription
hQry [in]Query handle.
arg1 [in]Database object name.
arg2 [in]An optional owner name; defaults to null.
arg3 [in]An optional qualifier name; defaults to null.
QRY_LISTTABLES$

Creates a result set (as if a script had been executed with QRY_EXECUTE$) of the tables in the connected database. The result set contains the columns QUALIFIER, OWNER, NAME, TYPE, and REMARKS.

ColumnDescription
QUALIFIEROften corresponds to the DOS path for local databases or the database name for SQL Server databases. It is datasource dependent.
OWNERFor datasources that support owners for objects, this specifies the owner of the object.
NAMEThe name of the object.
TYPEThe type of the object. This will usually be one of the following: SYSTEM TABLE, TABLE, GLOBAL TEMPORARY, LOCAL TEMPORARY, ALIAS, SYNONYM, VIEW, PROCEDURE, RULE, DEFAULT, or TRIGGER.
REMARKS

Miscellaneous information.

ValueDescription
hQry [in]Query handle.
arg1 [in]Object types. (Also defined in the insert DSXO_API.)
SymbolValueDescription
OBJ_DATATABLES$1Data tables
OBJ_SYSTABLES$2System tables
OBJ_TEMPTABLES$4Temporary tables
OBJ_VIEWS$8Views
OBJ_ALIASES$16Aliases
OBJ_PROCS$32Stored Procedures
OBJ_FUNCS$64Database functions
QRY_TRANSLATEFLAG$

Translates the bit-masked flag returned from the DS/XO API into TRUE$ for success and FALSE$ for failure; success includes both success and success with information (meaning possible pending messages) and failure includes an error (meaning possible pending messages), an invalid handle, and no more data.

ValueDescription
arg1 [in]The flag value returned from the DS/XO API.

Returns

TRUE for successful execution or FALSE for failure.

See also

XOGetProperty()-XO_TABLEDESCRIPT$

Remarks

* example for QryMethod:
function ExecuteScript(Script)
$insert XO_Equates
* returns @rm/@fm delimited results
Results = ""
* create connection (this could take params if you wanted,
* but calling it with no params lets the user choose what
* connection, etc.  this is how the query window calls it:
hXO  = XOInstance()
hQry = 0
if hXO then
   * create the query handle for the connection handle
   hQry = QryInstance(hXO)
   if hQry then
      * execute a script
      Flag = QryMethod(hQry, QRY_EXECUTE$, Script)
      if Flag then
         /* retrieve results and stick them in an @rm
            delimited array */
         loop
            Flag = QryMethod(hQry, QRY_GETROW$, Row)
         while Flag
            Results := @rm: Row
         repeat
         Results [1,1] = ""
         * cancel script
         Flag = QryMethod(hQry, QRY_CANCEL$)
      end else
         gosub error
      end
      * close the query handle
      Flag = QryMethod(hQry, QRY_DESTROY$)
   end else
      gosub error
   end
  * close the connection
  Flag = XOMethod(hXO, XO_DESTROY$)
end else
   gosub error
end
return Results
* Error handling
Error:
   if hQry then
      Flag = QryMethod(hQry, QRY_GETERROR$, "", "", "",|
                       "",Text)
   end else
      Flag = XOMethod(hXO, QRY_GETERROR$, "", "", "", |
                     "",Text)
   end
   convert @vm to @tm in Text
   Def = ""
   Def<MTEXT$>    = Text
   Def<MCAPTION$> = "ExecuteScript Error"
   Def<MICON$>    = "!"
   Msg(@window, Text)
   Results = ""
return
  • No labels