Books
in black and white
Main menu
Share a book About us Home
Books
Biology Business Chemistry Computers Culture Economics Fiction Games Guide History Management Mathematical Medicine Mental Fitnes Physics Psychology Scince Sport Technics
Ads

Teradata RDBMS forUNIX SQL Reference - NCR

NCR Teradata RDBMS forUNIX SQL Reference - NCR, 1997. - 913 p.
Download (direct link): teradataforunix1997.pdf
Previous << 1 .. 57 58 59 60 61 62 < 63 > 64 65 66 67 68 69 .. 241 >> Next


SELECT TITLE(Name) FROM Employee;

The returned data is:

TITLE(Name)

Name

The FORMAT(x) function returns a character string for the corresponding attribute of the specified operand (x). The data type returned by the FORMAT(x) phrases is a variable character string of up to 30 characters.

Teradata RDBMS for UNIX SQL Reference

5-105
Data Definition

Attribute Functions

This selects the FORMAT for the Salary column in the Employee Example table:

SELECT FORMAT(Salary) FROM Employee;

The result is:

FORMAT(Salary)

ZZZ,ZZ9.99 . . .

In the following example, the NAMED clause specifies a column name as part of the row information to accompany data which is returned:

SELECT empno, salary, NAMED(Salary) FROM employee WHERE empno = 10 019;

The result is:

EmpNo Salary Named(Salary)

10019 28,600.00 Salary

NAMED Function

In the following example, the NAMED clause specifies a column name as part of the row information to accompany data which is returned:

SELECT empno, salary, NAMED(salary) FROM employee WHERE empno = 10019 ;

EmpNo

10019

Salary

28,600.00

Named(Salary)

Salary

CHARACTERS and BYTES Functions

The CHARACTERS and BYTES attribute functions operate on an individual data value in the form of a character string or a byte string. Each function returns an integer value equal to the number of characters or bytes contained in the (edit) operand string.

CHARACTERS Function

The following statement applies the CHARACTERS function to the Name column, which is type VARCHAR, to obtain the number of characters in each employee name:

SELECT Name, CHARACTERS(Name) FROM Employee;

The result is as follows (note that separator blanks are considered characters):

Name

Characters(Name)

Smith T Newman P Omura H

Because trailing blanks are considered characters, the length of the value in a fixed-length column is always equal to the length defined for the column.

5-106

Teradata RDBMS for UNIX SQL Reference
Data Definition

Attribute Functions

The length of the value in a variable-length column is always equal to the number of characters, including any trailing blanks, contained in that value.

If you do not want trailing blanks included in the character count for a data value, use the TRIM function to suppress the trailing blanks in a value. The form for using TRIM with the CHARACTERS function is:

SELECTóCHARACTERS ó (TRIM (TRAILING F ROM expression))-

TJ

HH01A073

CHARACTERS can be abbreviated as CHARACTER, CHARS, or CHAR.

To use the TRIM function with a byte data value, substitute BYTES BYTES Function for CHARACTERS in the preceding example.

BYTES can be abbreviated as BYTE.

CHARACTERS and BYTES Functions for Japanese Character Sites

The data value for the CHARACTERS function can be a character or graphic string on a Japanese character supported site. The operation of the CHARACTERS function depends on the character set of the current session, as follows:

FOR this character set . . . AND this data type . . . AND this mode . . . CHARACTERS returns . . .
KanjiEBCDIC Graphic All the length of string_expr as the number of logical characters. Any trailing graphic pad characters are included in the result count.
Character Teradata returns the length of string_expr as the number of bytes. A mix of single and multibyte characters is expected. If any Shift-Out/Shift-In characters are present, they are included in the result count.
ANSI logical characters.

Teradata RDBMS for UNIX SQL Reference

5-107
Data Definition

Attribute Functions

FOR this character set . . . AND this data type . . . AND this mode . . . CHARACTERS returns . . .
KanjiEUC KanjiShift-JIS Graphic All the length of string_expr as the number of logical characters. Any trailing graphic pad characters are included in the result count. Note the unusual result given in the first example in Table 5-17
Character the length of string_expr as the number of logical characters, based on the character set of the current session. A mix of single and multibyte characters is expected.
ASCII EBCDIC Graphic All the length of string_expr as the number of logical characters. Any trailing graphic pad characters are included in the result count.
Character the length of string_expr as the number of bytes.

The following tables show examples of the count returned by the CHARACTERS function under each type of Kanji character set3.

Table 5-16 KanjiEBCDIC -CHARACTERS(string_expr)

string_expr Data Type Result
ABC Graphic 3
De<MNP> Character 10
<><> Character 4

3 < is Shift-Out, > is Shift-In, bold = double byte

5-108

Teradata RDBMS for UNIX SQL Reference
Table 5-17

KanjiEUC - CHARACTERS(string_expr)

Table 5-18 KanjiShift-JIS -CHARACTERS(string_expr)

MCHARACTERS

Function

Table 5-19 KanjiEBCDIC -

MCHARACTERS(string_expr)

Data Definition

Attribute Functions

string_expr Data Type Result
Previous << 1 .. 57 58 59 60 61 62 < 63 > 64 65 66 67 68 69 .. 241 >> Next