Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Semestr2 / 1 - Oracle / Oracle selected docs / SQL reference.pdf
Скачиваний:
24
Добавлен:
12.05.2015
Размер:
11.92 Mб
Скачать

TO_DSINTERVAL

ALTER SESSION SET NLS_TERRITORY = ’KOREAN’;

SELECT TO_DATE(

’January 15, 1989, 11:00 A.M.’, ’Month dd, YYYY, HH:MI A.M.’, ’NLS_DATE_LANGUAGE = American’) FROM DUAL;

TO_DATE(

--------

89/01/15

TO_DSINTERVAL

Syntax to_dsinterval::=

 

 

nlsparam

TO_DSINTERVAL

(

char

 

)

Purpose

TO_DSINTERVAL converts a character string of CHAR, VARCHAR2, NCHAR, or

NVARCHAR2 datatype to an INTERVAL DAY TO SECOND type.

char is the character string to be converted.

The only valid nlsparam you can specify in this function is NLS_NUMERIC_ CHARACTERS. This argument can have the form:

NLS_NUMERIC_CHARACTERS = "dg"

where d and g represent the decimal character and group separator respectively.

Examples

The following example selects from the employees table the employees who had worked for the company for at least 100 days on January 1, 1990:

SELECT employee_id, last_name FROM employees WHERE hire_date + TO_DSINTERVAL(’100 10:00:00’) <= DATE ’1990-01-01’;

Functions 6-177

TO_LOB

EMPLOYEE_ID LAST_NAME

----------- ---------------

100King

101Kochhar

200Whalen

TO_LOB

Syntax to_LOB::=

TO_LOB ( long_column )

Purpose

TO_LOB converts LONG or LONG RAW values in the column long_column to LOB values. You can apply this function only to a LONG or LONG RAW column, and only in the SELECT list of a subquery in an INSERT statement.

Before using this function, you must create a LOB column to receive the converted LONG values. To convert LONGs, create a CLOB column. To convert LONG RAWs, create a BLOB column.

Note: You cannot use the TO_LOB function to convert a LONG column to a LOB column in the subquery of a CREATE TABLE ...AS SELECT statement if you are creating an index-organized table. Instead, create the index-organized table without the LONG column, and then use the TO_LOB function in an INSERT ... AS SELECT statement.

See Also:

the modify_col_properties clause of ALTER TABLE on page 11-2 for an alternative method of converting LONG columns to LOB

INSERT on page 17-53 for information on the subquery of an INSERT statement

6-178 Oracle9i SQL Reference

TO_MULTI_BYTE

Examples

The sample table pm.print_media has a column press_release of type LONG. This example re-creates part of the table, with LOB data in the press_release column:

CREATE TABLE new_print_media ( product_id NUMBER(6), ad_id NUMBER(6), press_release CLOB);

INSERT INTO new_print_media

(SELECT p.product_id, p.ad_id, TO_LOB(p.press_release) FROM print_media p);

TO_MULTI_BYTE

Syntax to_multi_byte::=

TO_MULTI_BYTE ( char )

Purpose

TO_MULTI_BYTE returns char with all of its single-byte characters converted to their corresponding multibyte characters. char can be of datatype CHAR, VARCHAR2, NCHAR, or NVARCHAR2. The value returned is in the same datatype as char.

Any single-byte characters in char that have no multibyte equivalents appear in the output string as single-byte characters. This function is useful only if your database character set contains both single-byte and multibyte characters.

Note: This function does not support CLOB data directly. However, CLOBs can be passed in as arguments through implicit data conversion. Please refer to "Datatype Comparison Rules" on page 2-45 for more information.

Functions 6-179

TO_NCHAR (character)

Examples

The following example illustrates converting from a single byte ’A’ to a multibyte ’A’ in UTF8:

SELECT dump(TO_MULTI_BYTE( ’A’)) FROM DUAL;

DUMP(TO_MULTI_BYTE(’A’))

------------------------

Typ=1 Len=3: 239,188,161

TO_NCHAR (character)

Syntax to_nchar_char::=

 

 

char

,

nlsparam

 

 

fmt

 

 

 

 

 

,

 

 

 

TO_NCHAR

(

clob

 

 

 

)

 

 

nclob

 

 

 

 

Purpose

TO_NCHAR (character) converts a character string, CLOB, or NCLOB from the database character set to the national character set. This function is equivalent to the TRANSLATE ... USING function with a USING clause in the national character set.

See Also: "Data Conversion" on page 2-48 and TRANSLATE ...

USING on page 6-189

Examples

The following example converts NCLOB data from the pm.print_media table to the national character set:

SELECT TO_NCHAR(ad_fltextn) FROM print_media

WHERE product_id = 3106;

TO_NCHAR(AD_FLTEXTN)

------------------------------------------------------------------------

TIGER2 Tastaturen...weltweit fuehrend in Computer-Ergonomie. TIGER2 3106 Tastatur

Product Nummer: 3106

6-180 Oracle9i SQL Reference

Соседние файлы в папке Oracle selected docs