13.07.2015 Views

Reports & Queries - Source : www.pcsoft-windev-webdev.com

Reports & Queries - Source : www.pcsoft-windev-webdev.com

Reports & Queries - Source : www.pcsoft-windev-webdev.com

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

• To specify the query parameters, you must specify the initialization mode of the query.. notationTo pass parameters to a query, all the query parameters can be specified to the HFSQL engine before runningthe query. This method allows you to specify the parameters in any order (useful the for queries that requireseveral parameters).The following syntax must be used:. = . = …. = = HExecuteQuery( [, ] [, ])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.• No indirection operator and no dynamic <strong>com</strong>pilation (Compile) can 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 that were previously specifiedare ignored.• The value of the parameter can correspond to NULL.• If one of the parameters is not specified, the corresponding condition is ignored.Avoiding specifying all the parametersRegardless of the method used to pass parameters to the query, all the query parameters do not necessarilyhave to be specified. The query conditions that use unspecified parameters will be ignored.For example: let’s consider a query ("Customers_LastName_FirstName") whose SQL code is as follows:SELECT * FROM CUSTOMER WHERE LASTNAME= {Param1} AND FIRSTNAME = {Param2}• The 2 parameters are specified:HExecuteQuery(Customer_LastName_FirstName, hQueryDefault, "Smith", "John")will run the query:SELECT * FROM CUSTOMER WHERE NAME = ’Smith’ AND FIRSTNAME = ’John’• Only the last name is specified:HExecuteQuery(Customer_LastName_FirstName, hQueryDefault, "Smith")will run the query:SELECT * FROM CUSTOMER WHERE NAME = ’Smith’• Only the first name is specified. However, the name must be specified and it must correspond to Null.sName is Variant = Null// use the mandatory variant for the Null variable (not filled)HExecuteQuery(Customer_LastName_FirstName, hQueryDefault, sLastName, "John")OrHExecuteQuery(Customer_LastName_FirstName, hQueryDefault, Null, "John")will run the querySELECT * FROM CUSTOMER WHERE NAME = ’John’218Part 2: Query editor

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!