ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / Managing databases / HFSQL / HFSQL functions
  • 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/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
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:
  • This mode is intended for queries whose execution takes a few seconds. For immediate or almost immediate queries, this mode is too slow.
  • 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(REQ_MaRequete, hQueryDefault,
MaProcedurePourChaqueEnregistrement, MaProcedureFinale)
 
INTERNAL PROCÉDURE MaProcedurePourChaqueEnregistrement(enreg is Record of REQ_MaRequete)
Trace("Procédure de traitement de chaque enregistrement " + enreg.NomRubrique)
END
 
INTERNAL PROCÉDURE MaProcedureFinale(MonRes is int)
Trace("Procédure de traitement du résultat final")
SWITCH MonRes
CASE heqaOK:
Trace("La requête et le traitement des enregistrements se sont bien exécutés.")
CASE heqaCanceled:
Trace("Un traitement a renvoyé Faux. La requête et les procédures ont été annulées.")
OTHER CASE:
Trace("Une procédure ou l'exécution de la requête a rencontré une erreur.")
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
Name of query to be executed:
  • Name and full path of query (".WDR" file) to initialize.
    AndroidAndroid Widget 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 a variable of type SQL query.
<Mode>: Optional Integer constant
Option for initializing the query:
hQueryDefault
(default value)
Initialize the query.
hQueryWithoutCorrection
AndroidAndroid Widget 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 Classic 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.

AndroidAndroid Widget 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 <Nom de la procédure>(UnEnreg est un Enregistrement)
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 <Nom de la procédure>(nRésultat est un entier)
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 more details on 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
Name of query to be executed:
  • Name and full path of query (".WDR" file) to initialize.
    AndroidAndroid Widget 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 a variable of type SQL query.
<Connection>: Optional character string
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
AndroidAndroid Widget 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 Classic 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.

AndroidAndroid Widget 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 <Nom de la procédure>(UnEnreg est un Enregistrement)
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 <Nom de la procédure>(nRésultat est un entier)
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 more details on 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
WINDEVReports 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 with 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:
<Nom de la requête>.<Nom du paramètre 1> = xxx
<Nom de la requête>.<Nom du paramètre 2> = xxx
<Nom de la requête>.<Nom du paramètre 3> = xxx
HExécuteRequêteAsynchrone(<Nom de la requête>, <Procédure>)
SI ErreurDétectée = Vrai ALORS ...

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

Last update: 07/04/2023

Send a report | Local help