Cast

<< Click to Display Table of Contents >>

Navigation:  Using StreamLab > StreamLab Guides Overview > Guide Commands > Basic >

Cast

Previous pageReturn to chapter overviewNext page

CAST lets you convert one data type into another. To do so, enter the name of (or select) one or more columns. Then select a new data type for the column(s) and add size or precsion/scale specifications.

sl_cast_col

Precision specifies the maximum number of decimal digits that can be stored in the column, both to the right and to the left of the decimal point. You can specify precisions ranging from 1 digit to 18 digits or use the default precision of 18 digits.

Scale specifies the maximum number of digits that can be stored to the right of the decimal point. Scale must be less than or equal to the precision. You can specify a scale ranging from 0 digits to 18 digits, or use the default scale of 0 digits.

Valid conversions

Using CAST with source operands of the types listed in the first column below can create cast target types as listed in the second column, without restriction. Other target types are not supported.

Source Operand Types

Target Operand Types

Any numeric type

VARCHAR, CHAR, or any numeric type (See Note A.)

VARCHAR, CHAR

All of the above, plus, DATE, TIME, TIMESTAMP, DAY-TIME INTERVAL, BOOLEAN

DATE

DATE, VARCHAR, CHAR, TIMESTAMP

TIME

TIME, VARCHAR, CHAR, TIMESTAMP

TIMESTAMP

TIME, VARCHAR, CHAR, TIMESTAMP, DATE

DAY-TIME INTERVAL

DAY-TIME INTERVAL, BIGINT, DECIMAL, CHAR, VARCHAR

BOOLEAN

VARCHAR, CHAR, BOOLEAN

BINARY, VARBINARY

BINARY, VARBINARY