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
Required: YesvalueISTEXT
Required: YesvalueISBLANK
Required: YesvalueISEVEN
Required: YesnumberISODD
Required: YesnumberIS_ARRAY
Required: YesvalueIS_OBJECT
Required: YesvalueIS_NUMBER
Required: YesvalueIS_STRING
Required: YesvalueIS_NULL
Required: YesvalueTYPE
Required: Yesvalue
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.
| Function | Returns | Behaviour | Form |
|---|---|---|---|
ISNUMBER | true or false | True when the value is a number | ISNUMBER(5) |
ISTEXT | true or false | True when the value is text | ISTEXT("a") |
ISBLANK | true or false | True when the value is empty | ISBLANK(null) |
ISEVEN | true or false | True when the number is even | ISEVEN(4) |
ISODD | true or false | True when the number is odd | ISODD(4) |
IS_ARRAY | true or false | True when the value is a list | IS_ARRAY([1]) |
IS_OBJECT | true or false | True when the value is a record | IS_OBJECT({"a": 1}) |
IS_NUMBER | true or false | True when the value is a number | IS_NUMBER(5) |
IS_STRING | true or false | True when the value is text | IS_STRING("a") |
IS_NULL | true or false | True when the value is null | IS_NULL(null) |
TYPE | whole number | A 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 records | TYPE(5) |
Errors and exceptions
| Error | What happened | How to recover |
|---|---|---|
HTQL-5001 | The function was given the wrong number of arguments. The message names the function and the counts | Give it the arguments listed under Parameters |
HTQL-1004 Unsupported function | The name is not a function this engine runs | Check the name and its spelling against this entry |
HTQL-5004 | An IS_ function was given no argument | Pass the value to test |
HTQL-2005 | ISEVEN or ISODD was given text | Pass a number |
Limitations
ISNUMBER("5")is false: text that looks like a number is text.ISBLANKis true for null and for empty text, but not for 0.IS_NULLis true for null only.ISEVENandISODDrefuse text withHTQL-2005, and read a decimal such as4.5as its whole part.ISNUMBERandIS_NUMBERgive the same answers, as doISTEXTandIS_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.