17.10 - Examples - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - Data Types and Literals

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Release Date
July 2021
Content Type
Programming Reference
Publication ID
B035-1143-171K
Language
English (United States)

Example: CLOB Data Type

The following example creates a table that defines a CLOB column named clarge:

CREATE TABLE t1
  (id INTEGER
  ,clarge CLOB(2K) CHARACTER SET UNICODE);

SQL Engine stores the character data using the UNICODE server character set.

Example: Inserting CLOB Data

The following example shows a stored procedure that inserts part of a CLOB into one table and the remaining part of the CLOB into another table:

CREATE TABLE LocalData(ld_ID INTEGER, ld_DATA CLOB);
CREATE TABLE GlobalData (gd_ID INTEGER, gd_DATA CLOB);

CREATE PROCEDURE DataSplitter(IN local_ID  INTEGER,
                              IN global_ID INTEGER,
                              IN all_DATA  CLOB)

BEGIN

   INSERT LocalData (local_ID, SUBSTRING(all_DATA FROM 1 FOR 128546));
   INSERT GlobalData (global_ID, SUBSTRING(all_DATA FROM 128547));

END;