Sequences and number systems

Generate runs of numbers, add up a polynomial, and move whole numbers between Roman numerals and any base from 2 to 36.

Syntax

Write the function's name and its arguments, anywhere a value is allowed, such as inside RETURN.

SEQUENCE(rows, [columns], [start], [step])
SERIESSUM(x, n, m, coefficients)
ROMAN(number, [form])
BASE(number, radix, [min_length])
DECIMAL(text, base)

Parameters and arguments

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

  • SEQUENCE

    rows

    Required: Yes
  • columns

    Required: No
  • start

    Required: No
  • step

    Required: No
  • SERIESSUM

    x

    Required: Yes
  • n

    Required: Yes
  • m

    Required: Yes
  • coefficients

    Required: Yes
  • ROMAN

    number

    Required: Yes
  • form

    Required: No
  • BASE

    number

    Required: Yes
  • radix

    Required: Yes
  • min_length

    Required: No
  • DECIMAL

    text

    Required: Yes
  • base

    Required: Yes

Examples

A run of line numbers for an order, a grid of shelf positions, and pallet slots counted in tens from 100.

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
SEQUENCElist of rowsA grid of whole numbers filled row by row, each row a listSEQUENCE(2, 3)
SERIESSUMdecimalThe sum of each coefficient times x raised to its powerSERIESSUM(2.0, 0, 1, 1.0, 1.0, 1.0)
ROMANtextThe number as a Roman numeralROMAN(499)
BASEtextThe number written in the base, with lower case letters for digits above 9BASE(255, 16)
DECIMALwhole numberThe whole number the text stands forDECIMAL("ff", 16)
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-2001ROMAN was given a number outside 1 to 3999 or a form outside 0 to 4Pass a value in range
HTQL-2002BASE or DECIMAL was given a value outside its range, or text that is not a number in the baseCheck the number, the base and the text
Limitations
  • ROMAN refuses a number outside 1 to 3999 and a form outside 0 to 4 with HTQL-2001.
  • BASE refuses a negative number, a base outside 2 to 36 and a minimum length outside 0 to 255 with HTQL-2002. Letters in the answer are lower case, so BASE(255, 16) is ff.
  • DECIMAL needs its first argument as text in quotes and its base as a whole number. Text that is not a number in that base is refused with HTQL-2002.
  • SEQUENCE counts in whole numbers, so a decimal start or step is cut to a whole number.
  • SERIESSUM needs at least four arguments, so at least one coefficient.
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
  • Use SEQUENCE to number lines, pallet slots or shelf positions instead of counting in your own code.
  • Use BASE with a minimum length for fixed width codes, such as a label that is always four characters.
  • Use SERIESSUM for a cost formula with a fixed part, a per unit part and a squared part, so the whole formula is one call.