mvSQL database function - Type()¶
Summary¶
Since Vinyl 3.3.34775, this function provides Vinyl with information about the expression type without changing the expression itself. Unlike a CAST, this function is not rendered and does not affect the statement run by the target vendor.
This function is particularly useful in passthrough expressions, where Vinyl can't see the content of the expression.
Note
This function is purely for information purposes; it does not affect the inner expression, nor cast the value to the given type.
Syntax¶
Type(<expression> as <datatype>)
Parameters¶
-
expression
: A valid SQL expression, or reference to a column. -
datatype
: A valid SQL datatype. Supported datatypes include the following:Data type Example char(length)
char(12)
nvarchar(length)
nvarchar(123)
numeric(precision, scale)
numeric(10, 1)
Returns¶
The unchanged expression, while providing Vinyl with information about the resulting type.
Examples¶
TYPE(${SOUNDEX('Test')} AS Char(4))
This tells Vinyl that the passthrough expression returns a 4-character code, without altering the expression the vendor processes: SOUNDEX('Test')
.