PC SOFT

WINDEVWEBDEV AND WINDEV MOBILE
ONLINE HELP

Home | Sign in | English UK
  • Overview
  • Null and the queries
  • Ignoring the parameters: Null in HExecuteQuery
  • Parameters of a query coming from an edit control: Null if empty
  • Null and the variants
  • Null and the numeric values
  • Null and the WLanguage functions
  • Null and the dynamic objects
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
Overview
The Null keyword can be used according to different methods in WLanguage:
Versions 16 and later
Universal Windows 10 App This feature is available for the Windows Phone applications.
New in version 16
Universal Windows 10 App This feature is available for the Windows Phone applications.
Universal Windows 10 App This feature is available for the Windows Phone applications.
Versions 17 and later
iPhone/iPad This feature is available for the iPhone/iPad applications.
New in version 17
iPhone/iPad This feature is available for the iPhone/iPad applications.
iPhone/iPad This feature is available for the iPhone/iPad applications.
Versions 18 and later
Universal Windows 10 App This feature is available in Windows Store apps mode.
Android Widget This feature is available in Android Widget mode.
New in version 18
Universal Windows 10 App This feature is available in Windows Store apps mode.
Android Widget This feature is available in Android Widget mode.
Universal Windows 10 App This feature is available in Windows Store apps mode.
Android Widget This feature is available in Android Widget mode.
Versions 21 and later
Universal Windows 10 App This feature is available in Universal Windows 10 App mode.
Apple Watch This feature is available in Apple Watch mode.
New in version 21
Universal Windows 10 App This feature is available in Universal Windows 10 App mode.
Apple Watch This feature is available in Apple Watch mode.
Universal Windows 10 App This feature is available in Universal Windows 10 App mode.
Apple Watch This feature is available in Apple Watch mode.
Null and the queries

Ignoring the parameters: Null in HExecuteQuery

When a query with parameters is run by HExecuteQuery, some query parameters do not necessarily have to be specified. The query conditions that use parameters that are not specified or whose value is Null will be ignored.
Example: Let's consider the query named "Customer_LastName_FirstName" whose SQL code is as follows:
SELECT * FROM CUSTOMER WHERE LASTNAME = {Param1} AND FIRSTNAME = {Param2}
  • Case 1: The 2 parameters are specified
    HExecuteQuery(Customer_LastName_FirstName, hQueryDefault, "Smith", "John")

    will run the query:
    SELECT * FROM CUSTOMER WHERE LASTNAME = 'Smith' AND FIRSTNAME = 'John'
  • Case 2: Only the last name is specified
    HExecuteQuery(Customer_LastName_FirstName, hQueryDefault, "Smith")

    will run the query
    SELECT * FROM CUSTOMER WHERE LASTNAME= 'Smith'
  • Case 3: Only the first name is specified
    // use the mandatory variant for the Null variable (not filled)
    sLastName is Variant = Null
    HExecuteQuery(Customer_LastName_FirstName, hQueryDefault, sLastName, "Vince")

    Or
    HExecuteQuery(Customer_LastName_FirstName, hQueryDefault, Null, "Vince")

    will run the query
    SELECT * FROM CUSTOMER WHERE FIRSTNAME= 'John'

Parameters of a query coming from an edit control: Null if empty

In order for your query to be run even if no value was typed by the user, check "NULL if empty" for the edit controls ("Details" tab of control description).
When this option is checked, if the control is empty, the value of the parameter passed to the query will correspond to the NULL constant. Therefore, no error occurs when running the query: the conditions relative to this parameter will be ignored.
For example, the SQL code run is:
SELECT NameOfItems
FROM NameOfFiles
WHERE Item = {Param1}
The "Ex1" query is run in the "Btn_OK" button by HExecuteQuery. The WLanguage code used is as follows:
HExecuteQuery(Ex1, hQueryDefault, EDT_EditControl1)
In this code, EDT_EditControl1 corresponds to the control in which the user must enter the query parameter.
For this example, the table below describes the use of "NULL if empty":
Value entered by the user in EDT_EditControl1"NULL if empty" option checked for EDT_EditControl1SQL code run
No valueChecked option SELECT NameOfItems
FROM NameOfFiles
No valueOption uncheckedSELECT NameOfItems
FROM NameOfFiles
WHERE Item = ' '
A value is enteredOption checked or uncheckedSELECT NameOfItems
FROM NameOfFiles
WHERE Item = 'ValueEntered'
Null and the variants
To specify that a Variant variable contains no value, use the NULL constant.
Remarks:
  • For a variant type, NULL means "Not assigned"
  • For a numeric type, NULL means "equal to 0" (see below)
    vVal is Variant
    IF vVal = Null THEN ...
    // The test returns True because the variant is not assigned
    END

    vVal = 0
    IF vVal = Null THEN ...
    // The test returns False because the variant is assigned
    // with an integer whose value is 0
    END

    vVal = 5
    IF vVal = Null THEN ...
    // The test returns False because the variant is assigned
    // with an integer whose value is 5
    END
Null and the numeric values
Used with numeric values, Null enables you to compare a value to 0. The equality operators and the comparison operators can be used (= and <>).
Remarks:
  • For a variant type, NULL means "Not assigned" (see above)
  • For a numeric type, NULL means "equal to 0"
    nVal is int
    IF vVal = Null THEN ...
    // The test returns True because nVal=0
    END

    nVal = 5
    IF vVal = Null THEN ...
    // The test returns False because nVal=5
    END
Null and the WLanguage functions
Some WLanguage functions accept Null in parameter to specify that the parameter takes no value.
Some examples:
TreeAdd, TreeInsertNull allows you to display no image for the different levels of added elements.
TreeListItemNull is used to list the children from the root of the treeview.
TreeModifyNull allows you not to modify the image defined by TreeAdd
INIWriteNull is used to remove a keyword or a section from the INI file
Null and the dynamic objects
For the dynamic objects (class, structure, array, automation object, ...), Null is used to find out whether the object is allocated or not.
For example:
// Declare a dynamic automation object
MyDynamicObject is dynamic Automation object
...

IF MyDynamicObject = Null THEN
        // Create a dynamic automation object
        MyDynamicObject = new object Automation dynamic MyServer
END
Minimum version required
  • Version 10
This page is also available for…
Comments
Click [Add] to post a comment