VARGRAPHIC
Purpose
Returns the VARGRAPHIC representation of the character data in character_string_expression.
Syntax
where:
Syntax element … |
Specifies … |
character_string_expression |
a character string or character string expression for which the VARGRAPHIC representation is to be returned. |
ANSI Compliance
This is a Teradata extension to the ANSI SQL:2011 standard.
Argument Types
VARGRAPHIC operates on the following types of arguments:
If the argument is numeric, it is implicitly converted to a character type.
To define an implicit cast for a UDT, use the CREATE CAST statement and specify the AS ASSIGNMENT clause. For more information on CREATE CAST, see SQL Data Definition Language.
Implicit type conversion of UDTs for system operators and functions, including VARGRAPHIC, is a Teradata extension to the ANSI SQL standard. To disable this extension, set the DisableUDTImplCastForSysFuncOp field of the DBS Control Record to TRUE. For details, see Utilities: Volume 1 (A-K).
For more information on implicit type conversion, see Chapter 13: “Data Type Conversions.”
Result Type and Attributes
Here are the default result type and attributes for VARGRAPHIC(arg):
Data Type |
Heading |
VARCHAR(n) CHARACTER SET GRAPHIC |
Vargraphic(arg) |
Rules
VARGRAPHIC reports an error if the session character set is UTF8 or a single-byte character set, such as ASCII. If the argument is of type KANJI1, the only valid session character set is KanjiEBCDIC.
All characters in the string are converted into one or more graphics that are valid for the character set of the current session. For details, see “VARGRAPHIC Function Conversion Tables” on page 1280.
The argument cannot be of type GRAPHIC.
A result that exceeds the maximum length of a VARCHAR CHARACTER SET GRAPHIC data type generates an error.
VARGRAPHIC cannot appear as the first argument in a user-defined method invocation.
Specific rules apply to the server character set of character_string_expression.
IF the string specifies this server character set … |
THEN VARGRAPHIC operates as follows … |
KANJI1 |
Shift-Out/Shift-In characters in the character_string_expression do not appear in the result string. They are required only to indicate the transition between single byte characters and multibyte characters. Improperly placed Shift-Out/Shift-Ins are replaced by the illegal character for the character set of the session. The SPACE CHARACTER translates to the IDEOGRAPHIC SPACE CHARACTER. |
UNICODE |
|
anything else |
The result is as if string were first converted to UNICODE and then translated according to the rules listed for UNICODE above. |
Caution:
In accordance with Teradata internationalization plans, KANJI1 support is deprecated and is to be discontinued in the near future. KANJI1 is not allowed as a default character set; the system changes the KANJI1 default character set to the UNICODE character set. Creation of new KANJI1 objects is highly restricted. Although many KANJI1 queries and applications may continue to operate, sites using KANJI1 should convert to another character set as soon as possible. “”
Example
The following table shows examples of converting strings that use the UNICODE and LATIN server character sets to GRAPHIC data:
Function |
Result |
VARGRAPHIC('92 |
'92 |
VARGRAPHIC('abc') |
'abc' |
Example
Consider the following table definition with two character columns that use the KANJI1 server character set:
CREATE TABLE t1
(c1 VARCHAR(12) CHARACTER SET KANJI1
,c2 VARCHAR(12) CHARACTER SET KANJI1);
Use the KanjiEBCDIC client character set and insert the following strings:
INSERT t1 ('def', 'gH<ABC>X');
Convert the strings to GRAPHIC data:
Function |
Result |
SELECT VARGRAPHIC (c1) FROM t1; |
'def' |
SELECT VARGRAPHIC (c2) FROM t1; |
'gHABCX' (The single byte Hankaku Katakana X is converted to double byte X.) |