Movatterモバイル変換


[0]ホーム

URL:


Categories:

Semi-structured and structured data functions (Cast)

AS_INTEGER

Casts aVARIANT value to anINTEGER. The function doesnot cast non-integer values.

The INTEGER data type is synonymous with theNUMBER data type, except that precisionand scale can’t be specified for INTEGER values.

See also:

AS_<object_type>

AS_DECIMAL , AS_NUMBER ,AS_DOUBLE , AS_REAL

Syntax

AS_INTEGER(<variant_expr>)
Copy

Arguments

variant_expr

An expression that evaluates to a value of type VARIANT.

Returns

The function returns a value of type INTEGER or NULL:

  • If the type of the value in thevariant_expr argument is INTEGER, the function returns a value of type INTEGER.

  • If the type of the value in thevariant_expr argument doesn’t match the type of the outputvalue, the function returns NULL.

  • If thevariant_expr argument is NULL, the function returns NULL.

Examples

Create a table and load data into it:

CREATEORREPLACETABLEas_integer_example(integer1VARIANT);INSERTINTOas_integer_example(integer1)SELECTTO_VARIANT(15);
Copy

Use the AS_INTEGER function in a query to cast a VARIANT value to an INTEGER value:

SELECTAS_INTEGER(integer1)ASinteger_valueFROMas_integer_example;
Copy
+---------------+| INTEGER_VALUE ||---------------||            15 |+---------------+

Alternative interfaces


[8]ページ先頭

©2009-2026 Movatter.jp