Type checking functions

Ask what kind of value you are holding before you use it.

Syntax

Write the function's name and the value to test.

ISNUMBER(value)
ISTEXT(value)
ISBLANK(value)
ISEVEN(number)
ISODD(number)
IS_ARRAY(value)
IS_OBJECT(value)
IS_NUMBER(value)
IS_STRING(value)
IS_NULL(value)
TYPE(value)

Parameters and arguments

Arguments are written in brackets, separated by commas. An argument in square brackets is optional.

  • ISNUMBER

    value

    Required: Yes
  • ISTEXT

    value

    Required: Yes
  • ISBLANK

    value

    Required: Yes
  • ISEVEN

    number

    Required: Yes
  • ISODD

    number

    Required: Yes
  • IS_ARRAY

    value

    Required: Yes
  • IS_OBJECT

    value

    Required: Yes
  • IS_NUMBER

    value

    Required: Yes
  • IS_STRING

    value

    Required: Yes
  • IS_NULL

    value

    Required: Yes
  • TYPE

    value

    Required: Yes

Examples

A row from a spreadsheet import: the quantity arrived as text, the note is empty, and tags and meta are a list and a record.

Return type and behaviour

Each function returns one value. The table shows its type, what it does and one way to write it; the examples use the functions in realistic statements.

FunctionReturnsBehaviourForm
ISNUMBERtrue or falseTrue when the value is a numberISNUMBER(5)
ISTEXTtrue or falseTrue when the value is textISTEXT("a")
ISBLANKtrue or falseTrue when the value is emptyISBLANK(null)
ISEVENtrue or falseTrue when the number is evenISEVEN(4)
ISODDtrue or falseTrue when the number is oddISODD(4)
IS_ARRAYtrue or falseTrue when the value is a listIS_ARRAY([1])
IS_OBJECTtrue or falseTrue when the value is a recordIS_OBJECT({"a": 1})
IS_NUMBERtrue or falseTrue when the value is a numberIS_NUMBER(5)
IS_STRINGtrue or falseTrue when the value is textIS_STRING("a")
IS_NULLtrue or falseTrue when the value is nullIS_NULL(null)
TYPEwhole numberA code for the kind of value: 1 for a number, 2 for text, 4 for true or false, 16 for null and 64 for a list. A record also answers 1, so use IS_OBJECT for recordsTYPE(5)
Errors and exceptions
ErrorWhat happenedHow to recover
HTQL-5001The function was given the wrong number of arguments. The message names the function and the countsGive it the arguments listed under Parameters
HTQL-1004 Unsupported functionThe name is not a function this engine runsCheck the name and its spelling against this entry
HTQL-5004An IS_ function was given no argumentPass the value to test
HTQL-2005ISEVEN or ISODD was given textPass a number
Limitations
  • ISNUMBER("5") is false: text that looks like a number is text.
  • ISBLANK is true for null and for empty text, but not for 0. IS_NULL is true for null only.
  • ISEVEN and ISODD refuse text with HTQL-2005, and read a decimal such as 4.5 as its whole part.
  • ISNUMBER and IS_NUMBER give the same answers, as do ISTEXT and IS_STRING; use whichever spelling you prefer.
Permissions and security

These functions read nothing from your tables and write nothing.

When a function is applied to a column or a variable, the statement that reads the data needs read access, as its own entry says.

Best practices
  • Check a value's type before you convert it.
  • Use TO_NUMBER or VALUE to convert text that holds a number.