Example: CAST - Advanced SQL Engine - Teradata Database

SQL Operators and User-Defined Functions

Product
Advanced SQL Engine
Teradata Database
Release Number
17.00
Published
September 2020
Language
English (United States)
Last Update
2023-04-27
dita:mapPath
qqu1556127655717.ditamap
dita:ditavalPath
lze1555437562152.ditaval
dita:id
B035-1210
lifecycle
previous
Product Category
Teradata Vantage™

The following statement creates a table that defines a euro column named sales :

CREATE TABLE swiss_sales
  (location address
  ,sales euro);

The following statement uses CAST to return a euro UDT expression. Using CAST requires a cast definition that converts the DECIMAL(8,2) predefined type to a euro type.

INSERT INTO swiss_sales
   SELECT location, CAST (sales AS euro)
   FROM european_sales
   WHERE region = 1038;