This shows you the differences between two versions of the page.
dev:sql:functions:cast [2010/07/04 02:19] tdo |
dev:sql:functions:cast [2016/06/28 22:38] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | {{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}} | ||
- | ===== Description ===== | ||
- | The CAST function converts expressions to a specified data type. Column formatting will be the default for the specified data type. | ||
- | 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. | ||
- | ===== Syntax ===== | ||
- | CAST(scalar_expression AS datatype[(n)]) | ||
- | |||
- | == scalar_expression == | ||
- | Required. The column name that is to be cast. | ||
- | |||
- | == AS == | ||
- | Required | ||
- | |||
- | == datatype == | ||
- | Required. The supported SQL92 data type. | ||
- | |||
- | == n == | ||
- | Length if applicable. | ||
- | |||
- | ===== Examples ===== | ||
- | ==== Example 1 ==== | ||
- | <code SQL> | ||
- | select amount, | ||
- | cast(orders.amount as DOUBLE PRECISION) | ||
- | from orders where status='cncl'; | ||
- | </code> | ||
- | ==== Example 2 ==== | ||
- | <code SQL> | ||
- | select order_date, | ||
- | cast(substring(order_date from 1 for 2) as INTEGER) | ||
- | from orders | ||
- | where status='back'; | ||
- | </code> | ||
- | |||
- | |||
- | |||
- | {{page>:bottom_add&nofooter&noeditbtn}} |