ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / WLanguage syntax / Reserved keywords
  • Overview
  • Null and the queries
  • Ignoring the parameters: Null in HExecuteQuery
  • Query parameters 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
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Overview
The Null keyword can be used according to different methods in WLanguage:
Null and the queries

Ignoring the parameters: Null in HExecuteQuery

When running a query with parameters with HExecuteQuery, some query parameters do not have to be specified. The query conditions that use parameters that are not specified or whose value is Null will be ignored.
Example: Let the query "Customers_first_name" have the following SQL code:
SELECT * FROM CLIENT WHERE NOM = {Param1} AND PRENOM = {Param2}
  • Case 1: The 2 parameters are given
    HExecuteQuery(Clients_nom_prénom, hQueryDefault, "Dupond", "Jean")

    will run the query:
    SELECT * FROM CLIENT WHERE NOM = 'Dupond' AND PRENOM = 'Jean'
  • Case 2: Only the name is given
    HExecuteQuery(Clients_nom_prénom, hQueryDefault, "Dupond")

    will execute the query
    SELECT * FROM CLIENT WHERE NOM = 'Dupond'
  • Case 3: Only the first name is given
    // utilisation du variant obligatoire pour variable de type Null (non renseignée)
    sNom is Variant = Null 
    HExecuteQuery(Clients_nom_prénom, hQueryDefault, sNom, "Jean")

    Or
    HExecuteQuery(Clients_nom_prénom, hQueryDefault, Null, "Jean")

    will execute the query
    SELECT * FROM CLIENT WHERE PRENOM = 'Jean'

Query parameters 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. No error will occur when running the query: the conditions that depend on this parameter will be ignored.
For example, the SQL code run is:
SELECT NomDesRubriques
FROM NomDesFichiers
WHERE Rubrique = {Param1}
The "Ex1" query is run in the "Btn_OK" button by HExecuteQuery. The WLanguage code used is as follows:
HExecuteQuery(Ex1, hQueryDefault, SAI_ChampSaisie1)
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 ... 
    	// Le test renvoie Vrai car le variant n'est pas affecté
    END
     
    vVal = 0
    IF vVal = Null THEN ... 
    	// Le test renvoie Faux car le variant est affecté 
    	// avec un entier de valeur 0
    END
     
    vVal = 5
    IF vVal = Null THEN ... 
    	// Le test renvoie Faux car le variant est affecté
    	// avec un entier de valeur 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 nVal = Null THEN ... 
    	// Le test renvoie Vrai car nVal=0
    END
     
    nVal = 5
    IF nVal = Null THEN ... 
    	// Le test renvoie Faux car nVal=5
    END
Null and the WLanguage functions
Some WLanguage functions accept Null as parameter to specify that the parameter takes no value.
For example:
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:
// Déclaration d'un l'objet automation dynamique
MonObjetDynamique is object Automation dynamic
...

IF MonObjetDynamique = Null THEN
	// Création d'un l'objet automation dynamique
	MonObjetDynamique = new object Automation dynamic MonServeur
END
Minimum version required
  • Version 10
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 09/24/2024

Send a report | Local help