TurboSQL Guide General Functions and Operators |
Previous Top Next |

There is a list of functions and operators that can be used within TurboSQL expressions. This list is composed of a few standard SQL functions and a lot more additional TurboDB functions.

=

Syntax

expr1 = expr2

Description

Tests for equality.

<

Syntax

expr1 < expr2

Description

Tests whether expression expr1 is lower than expr2.

<=

Syntax

expr1 <= expr2

Description

Tests whether expression expr1 is lower or equal than expr2.

>

Syntax

expr1 > expr2

Description

Tests whether expression expr1 is greater than expr2.

>=

Syntax

expr1 >= expr2

Description

Tests whether expression expr1 is greater or equal than expr2.

BETWEEN ... AND ...

Syntax

expr1 BETWEEN expr2 AND expr3

Description

Tests whether expression expr1 is greater or equal than expr2 and lower or equal than expr3.

IN

Syntax

expr IN (expr1, expr2, expr3, ...)

Description

Tests whether expr is equal to one of the expressions expr1, expr2, expr3, ...

AND

Syntax

cond1 AND cond2

Description

Tests whether both cond1 and cond2 are true.

OR

Syntax

cond1 OR cond2

Description

Tests whether at least one of cond1 and cond2 is true.

NOT

Syntax

NOT cond

Description

Tests whether cond is false.

CASE

Syntax

CASE

WHEN cond1 THEN expr1

WHEN cond2 THEN expr2

...

[ELSE exprN]

END

CASE expr

WHEN exprA1 THEN exprB1

WHEN exprA2 THEN exprB2

...

[ELSE exprBN]

END

Description

The first form of the case operation determines the first expression for which the condition is true. The second one returns the B expression, who's A expression is equal to expr.

Samples

CASE WHEN Age < 8 THEN 'infant'WHEN Age < 18 THEN 'teenager' WHEN Age < 30 THEN 'twen' ELSE 'adult' END

CASE Status WHEN 0 THEN 'OK' WHEN 1 THEN 'WARNING' WHEN 2 THEN 'ERROR' END

CAST

Syntax

CAST(value AS type)

Description

Converts the value to the given type if possible. The cast operation may cut off strings and loose precision of decimal numbers. If the conversion is not possible, CAST raises an error.

Examples

CAST(time AS CHAR(10)) --Converts the time in its string representation

CAST(time AS CHAR(3)) --Displays only the first three characters

CAST(amount AS INTEGER)) --Looses the digits after the decimal point

CAST('abc' AS BIGINT) --Raises a conversion error

CAST(34515 AS BYTE) --Raises an overflow error

See also

General Functions and Operators

Arithmetic Functions and Operators

String Functions and Operators

Date and Time Functions and Operators

Aggregation Functions

Miscellaneous Functions and Operators