PC SOFT

ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Home | Sign in | English EN

New WINDEV and WINDEV Mobile 26 feature!
This content has been translated automatically. Click here to view the French version.
  • Why should the hQueryWithoutCorrection constant be used
  • Passing parameters to the query
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
Executes a SELECT query asynchronously. This query can correspond to:
  • a query created in the query editor.
  • an SQL Query variable.
Use conditions:
  • The query must be of type "SELECT": it must return records.
  • A query can only be executed asynchronously from the main context. In other cases, it is necessary to use threads.
  • This function does not allow passing parameters to a query that already has a parameter. Parameters must be passed before the query is executed.
HExecuteQueryAsynchronous(QRY_WDR3, MyCS2Connection,
hQueryDefault, MyProcedureForEachRecord, MyFinalProcedure)
 
INTERNAL PROCÉDURE MyProcedureForEachRecord(rec is Record)
Trace("Procedure for processing each Record" + rec.ItemName)
END
 
INTERNAL PROCÉDURE MyFinalProcedure(MyRes is int)
Trace("Procedure for processing the final result")
SWITCH MyRes
CASE heqaOK:
Trace("The query and the record processing were correctly executed.")
CASE heqaCanceled:
Trace("One process returned False. The query and the procedures have been canceled.")
OTHER CASE:
Trace("There was a problem with the procedure or with the execution of the query.")
END
END
Syntax

Executing a query (without connection) Hide the details

<Result> = HExecuteQueryAsynchronous(<Query name> [, <Mode>] , <WLanguage procedure for each record> [, <End WLanguage procedure>])
<Result>: boolean
  • True if the query was initialized (the SQL code of the query is valid),
  • False otherwise. HError returns more details about the problem.
<Query name>: Character string (with or without quotes)
Name of query to be executed:
  • Name and full path of query (".WDR" file) to initialize.
    Java Not available.
  • Logical name of the query to be initialized.
    If a query with the same name is already declared, it is replaced by the new query.
  • Name of an SQL query variable.
<Mode>: Optional Integer constant
Option for initializing the query:
hQueryDefault
(default value)
Initialize the query.
hQueryWithoutCorrection
JavaOLE DBNative Connectors (Native Accesses) No check is performed by the HFSQL engine. This option must be used if the query contains commands specific to a connection type (Oracle, SQL Server, etc.).
Caution: if this constant is used:
  • the connection name must be specified (<Connection> parameter).
  • you cannot cancel a condition by assigning it to NULL.
hQueryWithoutHFCorrection
HFSQL The file format (filled with space characters or not) is not checked by the HFSQL engine.
To be used if the query handles both HFSQL data files in a format that completes items with space characters and HFSQL data files in a format that does not complete items with space characters.

Java Android and Java (access by JDBC): This parameter can only correspond to the hQueryDefault or hQueryWithoutCorrection constant. If another constant is used, it will be ignored.
<WLanguage procedure for each record>: Procedure name
WLanguage procedure ("callback") executed for each record found corresponding to the query. This procedure has the following format:
PROCEDURE <Procedure name>(ARec is Record)
where <ARec> is a Record variable that corresponds to the current record (for the executed query).
By default, the procedure returns True and goes to the next record.
If this procedure returns False, the query is canceled and the <End WLanguage procedure> is executed.
<End WLanguage procedure>: Optional procedure name
WLanguage procedure ("callback") executed at the end of the execution of the query. This procedure has the following format:
PROCEDURE <Procedure name>(nResult is int)
where <nResult> is an Integer constant that can correspond to the following values:
heqaCanceledThe procedure executed for each record returned False. The query and the different procedures were canceled.
heqaErrorThe query and/or the procedure called for each record encountered an error. You can get the details of the error with HErrorInfo.
heqaOKThe query and the procedure were correctly executed for each record.
Remark: The query is destroyed once all records have been read. The <End WLanguage procedure> can only be used to know how the iteration ended.

Executing a query via a connection Hide the details

<Result> = HExecuteQueryAsynchronous(<Query name> [, <Connection> [, <Mode>]] , <WLanguage procedure for each record> [, <End WLanguage procedure>])
<Result>: boolean
  • True if the query was initialized (the SQL code of the query is valid),
  • False otherwise. HError returns more details about the problem.
<Query name>: Character string (with or without quotes)
Name of query to be executed:
  • Name and full path of query (".WDR" file) to initialize.
    Java Not available.
  • Logical name of the query to be initialized.
    If a query with the same name is already declared, it is replaced by the new query.
  • Name of an SQL query variable.
<Connection>: Optional character string (with or without quotes)
Name of the connection, defined in the data model editor or dynamically with HDescribeConnection. The query will be executed via this connection.
OLE DBNative Connectors (Native Accesses) If this parameter is not specified and the query affects data files accessed via OLE DB or Native Connectors, the query is executed via the connection used by the first data file found in the query. If the connection used by a data file is modified before the call to HExecuteQueryAsynchronous, the new connection will be used.
<Mode>: Optional Integer constant
Option for initializing the query:
hQueryDefault
(default value)
Initialize the query.
hQueryWithoutCorrection
JavaOLE DBNative Connectors (Native Accesses) No check is performed by the HFSQL engine. This option must be used if the query contains commands specific to a connection type (Oracle, SQL Server, etc.).
Caution: if this constant is used:
  • the connection name must be specified (<Connection> parameter).
  • you cannot cancel a condition by assigning it to NULL.
hQueryWithoutHFCorrection
HFSQL The file format (filled with space characters or not) is not checked by the HFSQL engine.
To be used if the query handles both HFSQL data files in a format that completes items with space characters and HFSQL data files in a format that does not complete items with space characters.

Java Android and Java (access by JDBC): This parameter can only correspond to the hQueryDefault or hQueryWithoutCorrection constant. If another constant is used, it will be ignored.
<WLanguage procedure for each record>: Procedure name
WLanguage procedure ("callback") executed for each record found corresponding to the query. This procedure has the following format:
PROCEDURE <Procedure name>(ARec is Record)
where <ARec> is a Record variable that corresponds to the current record (for the executed query).
By default, the procedure returns True and goes to the next record.
If this procedure returns False, the query is canceled and the <End WLanguage procedure> is executed.
<End WLanguage procedure>: Optional procedure name
WLanguage procedure ("callback") executed at the end of the execution of the query. This procedure has the following format:
PROCEDURE <Procedure name>(nResult is int)
where <nResult> is an Integer constant that can correspond to the following values:
heqaCanceledThe procedure executed for each record returned False. The query and the different procedures were canceled.
heqaErrorThe query and/or the procedure called for each record encountered an error. You can get the details of the error with HErrorInfo.
heqaOKThe query and the procedure were correctly executed for each record.
Remark: The query is destroyed once all records have been read. The <End WLanguage procedure> can only be used to know how the iteration ended.
Remarks
Reports and QueriesUser code (UMC)OLE DBNative Connectors (Native Accesses)

Why should the hQueryWithoutCorrection constant be used

By default, WINDEV and WEBDEV interpret the SQL queries on OLE DB and on ODBC via the OLE DB provider. To prevent the query from being interpreted, use the hQueryWithoutCorrection constant.
The hQueryWithoutCorrection constant can be used if you directly enter the SQL code of your query in the query editor.
hQueryWithoutCorrection is not specifiedhQueryWithoutCorrection is specified
The connection associated with the data files in the query is defined automatically.The connection to use must be specified in HExecuteSQLQuery.
All PC SOFT proprietary signs are replaced (e.g.: ']=' starts with) with their equivalent in standard SQL.No replacement is performed. The standard SQL symbols must be used.
Dates and times adopt the format used by the database.
For example, the dates are in 'YYYYMMDD' format in WINDEV and WEBDEV while in Access, the dates are in #YYYYDDMM# or #YYYYMMDD# format depending on the system language.
No formatting is performed. The format recognized by the database must be used.
Floats are formatted (the decimal separator can be '.' or ',')No formatting is performed for the floats.
Depending on the database used, the alias names are replaced by the full names of the items in Where, Order by and Group by
For example, the JET engine (Access, dBase, etc.) accepts no alias name in the Where clause of a query
No replacement is performed. The full names of items must be used in the query code for Where, Order by and Group by.

Passing parameters to the query

To pass parameters to a query before executing it, the following syntax must also be used:
<Query name>.<Name of parameter 1> = xxx
<Query name>.<Name of parameter 2> = xxx
<Query name>.<Name of parameter 3> = xxx
HExecuteQueryAsynchronous(<Query name>, <Procedure>)
IF ErrorOccurred = True THEN ...

Remark: The structure of the query parameters is reset each time the query is executed.
Business / UI classification: Business Logic
Component: wd260hf.dll
Minimum version required
  • Version 26
This page is also available for…
Comments
Click [Add] to post a comment