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

ROWIDTONCHAR

ROWIDTOCHAR

Syntax rowidtochar::=

ROWIDTOCHAR ( rowid )

Purpose

ROWIDTOCHAR converts a rowid value to VARCHAR2 datatype. The result of this conversion is always 18 characters long.

Examples

The following example converts a rowid value in the employees table to a character value. (Results vary for each build of the sample database.)

SELECT ROWID FROM employees

WHERE ROWIDTOCHAR(ROWID) LIKE ’%SAAb%’;

ROWID

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

AAAFfIAAFAAAABSAAb

ROWIDTONCHAR

Syntax rowidtonchar::=

ROWIDTONCHAR ( rowid )

Purpose

ROWIDTONCHAR converts a rowid value to NVARCHAR2 datatype. The result of this conversion is always 18 characters long.

Examples

SELECT LENGTHB( ROWIDTONCHAR(ROWID) ), ROWIDTONCHAR(ROWID)

FROM employees;

Functions 6-141

RPAD

LENGTHB(ROWIDTONCHAR(ROWID)) ROWIDTONCHAR(ROWID

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

36 AAAFfIAAFAAAABSAAA

.

.

.

RPAD

Syntax rpad::=

 

 

 

 

,

char2

RPAD

(

char1

,

n

)

Purpose

RPAD returns char1, right-padded to length n with char2, replicated as many times as necessary; char2 defaults to a single blank. If char1 is longer than n, then this function returns the portion of char1 that fits in n.

Both char1 and char2 can be any of the datatypes CHAR, VARCHAR2, NCHAR, NVARCHAR2, CLOB, or NCLOB. The string returned is of VARCHAR2 datatype and is in the same character set as char1.

The argument n is the total length of the return value as it is displayed on your terminal screen. In most character sets, this is also the number of characters in the return value. However, in some multibyte character sets, the display length of a character string can differ from the number of characters in the string.

Examples

The following example right-pads a name with the letters "ab" until it is 12 characters long:

SELECT RPAD(’MORRISON’,12,’ab’) "RPAD example"

FROM DUAL;

RPAD example

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

MORRISONabab

6-142 Oracle9i SQL Reference

SESSIONTIMEZONE

RTRIM

Syntax rtrim::=

 

 

,

set

RTRIM

(

char

)

Purpose

RTRIM returns char, with all the rightmost characters that appear in set removed; set defaults to a single blank. If char is a character literal, then you must enclose it in single quotes. RTRIM works similarly to LTRIM.

Both char and set can be any of the datatypes CHAR, VARCHAR2, NCHAR, NVARCHAR2, CLOB, or NCLOB. The string returned is of VARCHAR2 datatype and is in the same character set as char.

Examples

The following example trims the letters "xy" from the right side of a string:

SELECT RTRIM(’BROWNINGyxXxy’,’xy’) "RTRIM example"

FROM DUAL;

RTRIM examp

-----------

BROWNINGyxX

See Also: LTRIM on page 6-93

SESSIONTIMEZONE

Syntax sessiontimezone::=

SESSIONTIMEZONE

Purpose

SESSIONTIMEZONE returns the value of the current session’s time zone. The return type is a time zone offset (a character type in the format ’[+|]TZH:TZM’) or a time

Functions 6-143

SIGN

zone region name, depending on how the user specified the session time zone value in the most recent ALTER SESSION statement.

Note: You can set the default client session time zone using the

ORA_SDTZ environment variable. Please refer to Oracle9i Database

Globalization Support Guide for more information on this variable.

Examples

The following example returns the current session’s time zone:

SELECT SESSIONTIMEZONE FROM DUAL;

SESSION

-------

-08:00

SIGN

Syntax sign::=

SIGN ( n )

Purpose

SIGN returns -1 if n<0, then . If n=0, then the function returns 0. If n>0, then SIGN returns 1.

Examples

The following example indicates that the function’s argument (-15) is <0:

SELECT SIGN(-15) "Sign" FROM DUAL;

Sign

----------

-1

6-144 Oracle9i SQL Reference

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