15.00 - INTERVAL-to-UDT Conversion - Teradata Database

Teradata Database SQL Functions, Operators, Expressions, and Predicates

Product
Teradata Database
Release Number
15.00
Content Type
Programming Reference
Publication ID
B035-1145-015K
Language
English (United States)

INTERVAL-to-UDT Conversion

Purpose

Converts interval data to UDT data.

CAST Syntax

where:

 

Syntax element …

Specifies …

interval_expression

an interval expression to be cast to a UDT.

UDT_data_definition

the UDT type to which interval_expression is to be converted.

ANSI Compliance

This is ANSI SQL:2011 compliant.

As an extension to ANSI, CAST permits the use of data attribute phrases such as FORMAT.

Usage Notes

Explicit INTERVAL-to-UDT conversion using Teradata conversion syntax is not supported.

Data type conversions involving UDTs require appropriate cast definitions for the UDTs. To define a cast for a UDT, use the CREATE CAST statement. For more information on CREATE CAST, see SQL Data Definition Language.

Implicit INTERVAL-to-UDT Conversion

Performing an implicit data type conversion requires a cast definition (see “Usage Notes” on page 662) that specifies the following:

  • the AS ASSIGNMENT clause
  • a source data type that is in the same INTERVAL family as the source of the implicit cast:
  •  

    This INTERVAL data type …

    Belongs to this INTERVAL family …

  • INTERVAL YEAR
  • INTERVAL YEAR TO MONTH
  • INTERVAL MONTH
  • Year-Month

  • INTERVAL DAY
  • INTERVAL DAY TO HOUR
  • INTERVAL DAY TO MINUTE
  • INTERVAL DAY TO SECOND
  • INTERVAL HOUR
  • INTERVAL HOUR TO MINUTE
  • INTERVAL HOUR TO SECOND
  • INTERVAL MINUTE
  • INTERVAL MINUTE TO SECOND
  • INTERVAL SECOND
  • Day-Time

    The source data type of the cast definition does not have to be an exact match to the source of the implicit type conversion.

    Teradata Database performs implicit INTERVAL-to-UDT conversions for the following operations:

  • UPDATE
  • INSERT
  • Passing arguments to stored procedures, external stored procedures, UDFs, and UDMs
  • Specific system operators and functions identified in other sections of this book, unless the DisableUDTImplCastForSysFuncOp field of the DBS Control Record is set to TRUE
  • Related Topics

    For details on data types and data attributes, see SQL Data Types and Literals.