PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
  • Overview
  • Using HExecuteQuery to pass parameters to a query
  • Syntax to use
  • Using the . notation
  • Syntax to use
  • Avoid specifying all the parameters
  • Unspecified query parameters
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
Two methods for passing parameters to a query
Overview
Two methods can be used to pass parameters to a query with parameters used in a window or in a control (List Box, Combo Box or Table control for example):
This help page presents the operating mode and the benefits of each one of these methods.
Note: The method for passing parameters differs if the query with parameters is used in a report. See How to use a query with parameters in a report for more details.
Note: From version 19, HFSQL is the new name of HyperFileSQL.
Using HExecuteQuery to pass parameters to a query

Syntax to use

When a query is run by HExecuteQuery, the last parameters passed to the function correspond to the parameters of the query.
The following syntax is used:
<Result> = HExecuteQuery(<Query Name> [, <Connection>] [, <Mode>
[ , <Parameters> [, ...]]])
Caution: In this case:
  • The values of the query parameters must be specified in their initialization order (visible in the query editor). Each parameter must correspond to the expected type. The different parameters are separated by a comma.
  • To specify the parameters of the query, you must specify the initialization mode of the query.
Using the <Query Name>.<Parameter Name> notation

Syntax to use

To pass parameters to a query, all the query parameters can be specified to the HFSQL engine before running the query. This method allows you to specify the parameters in any order (useful for the queries that require several parameters).
The following syntax must be used:
<Query Name>.<Name of Parameter 1> = <Value of Parameter 1>
<Query Name>.<Name of Parameter 2> = <Value of Parameter 2>
...
<Query Name>.<Name of Parameter N> = <Value of Parameter N>

<Result> = HExecuteQuery(<Query Name>
[ , <Connection>] [, <Mode>])
Caution:
  • The name of the parameter must be the name specified when the query was created in the query editor. This name must differ from an item name.
  • The indirection operators or the dynamic compilation (Compile) cannot be used with this syntax.
  • The parameters are reinitialized (reset to 0) whenever the query is run by HExecuteQuery.
  • If at least one parameter is specified in HExecuteQuery, all the parameters specified beforehand are ignored.
  • The value of the parameter can correspond to NULL.
  • If one of the parameters is not specified, the corresponding condition is ignored.
PHP All the expected parameters must necessarily be entered.
AndroidJava All the expected parameters must necessarily be entered.
Avoid specifying all the parameters
WINDEVWEBDEV - Server codeReports and QueriesWindowsAndroidiPhone/iPadWindows MobileJavaHFSQLHFSQL Client/ServerHyper File 5.5OLE DBODBCNative Accesses

Unspecified query parameters

Regardless of the method used to pass parameters to the query, all the query parameters do not necessarily have to be specified. The query conditions that use unspecified parameters will be ignored.
Example: Let's consider the "QRY_Customer_LastName_FirstName" query whose SQL code is as follows:
SELECT * FROM CUSTOMER WHERE LASTNAME = {Param1} AND FIRSTNAME = {Param2}
  • The 2 parameters are specified:
    HExecuteQuery(QRY_Customers_LName_FName, hQueryDefault, ...
    "Smith", "John")
    will run the query
    SELECT * FROM CUSTOMER WHERE LASTNAME = 'Smith' AND FIRSTNAME = 'John'
  • Only the name is specified:
    HExecuteQuery(QRY_Customer_LastName_FirstName, hQueryDefault, "Smith" )
    will run the query
    SELECT * FROM CUSTOMER WHERE LASTNAME= 'Smith'
  • Only the first name is specified. However, the name must be specified and it must correspond to Null.
    sName is Variant = Null
    // Use of variant required
    // for the Null variable (not filled)

    HExecuteQuery(QRY_Customers_LName_FName, hQueryDefault, ...
    sLastName, "John")

    // OR

    HExecuteQuery(QRY_Customers_LName_FName, hQueryDefault, ...
    Null, "John")
    will run the query:
    SELECT * FROM CUSTOMER WHERE FIRSTNAME= 'John'
AndroidJava Note: All the expected parameters must necessarily be entered.
Minimum required version
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment