This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
dev:sql:functions:cast [2010/07/04 02:18] tdo |
dev:sql:functions:cast [2016/06/28 22:38] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
{{page>:top_add&nofooter&noeditbtn}} | {{page>:top_add&nofooter&noeditbtn}} | ||
- | <html><div align="center"><span style="color:red">DRAFT</span></div></html> | ||
- | ====== Omnidex SQL Function: CASE ====== | ||
{{page>:sql_bar&nofooter&noeditbtn}} | {{page>:sql_bar&nofooter&noeditbtn}} | ||
+ | ====== Omnidex SQL Function: CAST ====== | ||
===== Description ===== | ===== Description ===== | ||
- | The CAST function converts expressions to a specified data type. Column formatting will be the default for the specified data type. | + | The CAST function converts an expression to the requested datatype. |
- | Due to conflicts in specifications, the main OmniAccess data types are not supported here. The $CONVERT function should be used for OmniAccess data types and for more specific functions. | + | This function returns the datatype requested in the function. |
===== Syntax ===== | ===== Syntax ===== | ||
- | CAST(scalar_expression AS datatype[(n)]) | ||
- | == scalar_expression == | + | CAST(expression AS datatype) |
- | Required. The column name that is to be cast. | + | |
- | == AS == | + | == expression == |
- | Required | + | |
+ | Required. An expression using SQL language that produces a value. A scalar expression is generally equivalent to a select item in the SQL SELECT statement, and can be a character expression, numeric expression or date expression. | ||
== datatype == | == datatype == | ||
- | Required. The supported SQL92 data type. | + | Required. One of the datatypes listed below: |
- | == n == | + | {{page>dev:appendix:reference:datatypes_insert&noheader&nofooter&noeditbtn}} |
- | Length if applicable. | + | |
- | ===== Examples ===== | + | Omnidex also provides partial support for National Character Datatypes (sometimes called Unicode datatypes or wide characters). The Omnidex SQL Engine will process these datatypes, but the Omnidex Indexing Engine will only index the lower 8 bits of these datatypes. |
- | ==== Example 1 ==== | + | |
- | <code SQL> | + | |
- | select amount, | + | |
- | cast(orders.amount as DOUBLE PRECISION) | + | |
- | from orders where status='cncl'; | + | |
- | </code> | + | |
- | ==== Example 2 ==== | + | {{page>dev:appendix:reference:natl_datatypes_insert&noheader&nofooter&noeditbtn}} |
- | <code SQL> | + | |
- | select order_date, | + | ===== Example ===== |
- | cast(substring(order_date from 1 for 2) as INTEGER) | + | ==== Example 1: CAST of column ==== |
- | from orders | + | |
- | where status='back' | + | <code> |
+ | > select cast(individual as integer) ind from individuals; | ||
+ | |||
+ | IND | ||
+ | ----------- | ||
+ | 900011022 | ||
+ | 900047761 | ||
+ | 900047762 | ||
+ | 900067115 | ||
+ | 900067114 | ||
+ | 900215567 | ||
+ | 900240828 | ||
</code> | </code> | ||
+ | |||
+ | ====== Additional Resources ====== | ||
+ | |||
+ | See also: | ||
+ | {{page>dev:sql:functions:see_also_utility&noheader&nofooter&noeditbtn}} | ||
{{page>:bottom_add&nofooter&noeditbtn}} | {{page>:bottom_add&nofooter&noeditbtn}} |