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

TANH

TAN

Syntax tan::=

TAN ( n )

Purpose

TAN returns the tangent of n (an angle expressed in radians).

Examples

The following example returns the tangent of 135 degrees:

SELECT TAN(135 * 3.14159265359/180) "Tangent of 135 degrees" FROM DUAL;

Tangent of 135 degrees

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

- 1

TANH

Syntax tanh::=

TANH ( n )

Purpose

TANH returns the hyperbolic tangent of n.

Examples

The following example returns the hyperbolic tangent of .5:

SELECT TANH(.5) "Hyperbolic tangent of .5"

FROM DUAL;

Hyperbolic tangent of .5

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

.462117157

Functions 6-169

TO_CHAR (character)

TO_CHAR (character)

Syntax to_char_char::=

 

 

nchar

 

TO_CHAR

(

clob

)

 

 

nclob

 

Purpose

TO_CHAR (character) converts NCHAR, NVARCHAR2, CLOB, or NCLOB data to the database character set.

Examples

The following example interprets a simple string as character data:

SELECT TO_CHAR(’01110’) FROM DUAL;

TO_CH

-----

01110

Compare this example with the first example for TO_CHAR (number) on page 6-173.

The following example converts some CLOB data from the pm.print_media table to the database character set:

SELECT TO_CHAR(ad_sourcetext) FROM print_media

WHERE product_id = 2268;

TO_CHAR(AD_SOURCETEXT)

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

******************************

TIGER2 2268...Standard Hayes Compatible Modem Product ID: 2268

The #1 selling modem in the universe! Tiger2’s modem includes call management and Internet voicing. Make real-time full duplex phone calls at the same time you’re online.

**********************************

6-170 Oracle9i SQL Reference

TO_CHAR (datetime)

TO_CHAR (datetime)

Syntax to_char_date::=

 

 

 

,

nlsparam

 

 

,

fmt

 

 

 

TO_CHAR

(

date

 

 

 

)

Purpose

TO_CHAR (datetime) converts date of DATE, TIMESTAMP, TIMESTAMP WITH TIME ZONE, or TIMESTAMP WITH LOCAL TIME ZONE datatype to a value of VARCHAR2 datatype in the format specified by the date format fmt. If you omit fmt, then date is converted to a VARCHAR2 value as follows:

DATE is converted to a value in the default date format.

TIMESTAMP and TIMESTAMP WITH LOCAL TIME ZONE are converted to values in the default timestamp format.

TIMESTAMP WITH TIME ZONE is converted to a value in the default timestamp with time zone format.

The ’nlsparams’ specifies the language in which month and day names and abbreviations are returned. This argument can have this form:

’NLS_DATE_LANGUAGE = language’

If you omit ’nlsparams’, then this function uses the default date language for your session.

See Also: "Format Models" on page 2-61 for information on date formats

Examples

The following example uses this table:

CREATE TABLE date_tab (

ts_col

TIMESTAMP,

tsltz_col

TIMESTAMP WITH LOCAL TIME ZONE,

tstz_col

TIMESTAMP WITH TIME ZONE);

Functions 6-171

TO_CHAR (datetime)

The example shows the results of applying TO_CHAR to different TIMESTAMP datatypes. The result for a TIMESTAMP WITH LOCAL TIME ZONE column is sensitive to session time zone, whereas the results for the TIMESTAMP and TIMESTAMP WITH TIME ZONE columns are not sensitive to session time zone:

ALTER SESSION SET TIME_ZONE = ’-8:00’;

INSERT INTO date_tab VALUES (

TIMESTAMP’1999-12-01 10:00:00’,

TIMESTAMP’1999-12-01 10:00:00’,

TIMESTAMP’1999-12-01 10:00:00’);

INSERT INTO date_tab VALUES (

TIMESTAMP’1999-12-02 10:00:00 -8:00’,

TIMESTAMP’1999-12-02 10:00:00 -8:00’,

TIMESTAMP’1999-12-02 10:00:00 -8:00’);

SELECT TO_CHAR(ts_col, ’DD-MON-YYYY HH24:MI:SSxFF’), TO_CHAR(tstz_col, ’DD-MON-YYYY HH24:MI:SSxFF TZH:TZM’) FROM date_tab;

TO_CHAR(TS_COL,’DD-MON-YYYYHH2 TO_CHAR(TSTZ_COL,’DD-MON-YYYYHH24:MI:

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

01-DEC-1999 10:00:00 01-DEC-1999 10:00:00.000000 -08:00 02-DEC-1999 10:00:00 02-DEC-1999 10:00:00.000000 -08:00

SELECT SESSIONTIMEZONE,

TO_CHAR(tsltz_col, ’DD-MON-YYYY HH24:MI:SSxFF’)

FROM date_tab;

SESSIONTIMEZONE TO_CHAR(TSLTZ_COL,’DD-MON-YYYY

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

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

-08:00

01-DEC-1999

10:00:00.000000

-08:00

02-DEC-1999

10:00:00.000000

ALTER SESSION SET TIME_ZONE = ’-5:00’;

SELECT TO_CHAR(ts_col, ’DD-MON-YYYY HH24:MI:SSxFF’), TO_CHAR(tstz_col, ’DD-MON-YYYY HH24:MI:SSxFF TZH:TZM’) FROM date_tab;

TO_CHAR(TS_COL,’DD-MON-YYYYHH2 TO_CHAR(TSTZ_COL,’DD-MON-YYYYHH24:MI:

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

01-DEC-1999 10:00:00.000000 01-DEC-1999 10:00:00.000000 -08:00 02-DEC-1999 10:00:00.000000 02-DEC-1999 10:00:00.000000 -08:00

6-172 Oracle9i SQL Reference

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