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

EXISTSNODE

EMPTY_BLOB, EMPTY_CLOB

Syntax empty_LOB::=

EMPTY_BLOB

( )

EMPTY_CLOB

Purpose

EMPTY_BLOB and EMPTY_CLOB return an empty LOB locator that can be used to initialize a LOB variable or, in an INSERT or UPDATE statement, to initialize a LOB column or attribute to EMPTY. EMPTY means that the LOB is initialized, but not populated with data.

Restriction on LOB Locators You cannot use the locator returned from this function as a parameter to the DBMS_LOB package or the OCI.

Examples

The following example initializes the ad_photo column of the sample pm.print_ media table to EMPTY:

UPDATE print_media SET ad_photo = EMPTY_BLOB();

EXISTSNODE

Syntax existsnode::=

 

 

 

 

,

namespace_string

EXISTSNODE

(

XMLType_instance

,

XPath_string

)

Purpose

EXISTSNODE determines whether traversal of the document using the path results in any nodes. It takes as arguments the XMLType instance containing an XML document and a VARCHAR2 XPath string designating a path. The optional namespace_string must resolve to a VARCHAR2 value that specifies a default

Functions 6-61

EXP

mapping or namespace mapping for prefixes, which Oracle uses when evaluating the XPath expression(s).

The return value is NUMBER:

0 if no nodes remain after applying the XPath traversal on the document

1 if any nodes remain

Examples

The following example tests for the existence of the /Warehouse/Dock node in the XML path of the warehouse_spec column of the sample table oe.warehouses:

SELECT warehouse_id, warehouse_name

FROM warehouses

WHERE EXISTSNODE(warehouse_spec, ’/Warehouse/Docks’) = 1;

WAREHOUSE_ID

WAREHOUSE_NAME

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

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

1

Southlake, Texas

2

San Francisco

4

Seattle, Washington

EXP

Syntax exp::=

EXP ( n )

Purpose

EXP returns e raised to the nth power, where e = 2.71828183 ...

Examples

The following example returns e to the 4th power:

SELECT EXP(4) "e to the 4th power" FROM DUAL;

e to the 4th power

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

54.59815

6-62 Oracle9i SQL Reference

EXTRACT (datetime)

EXTRACT (datetime)

Syntax extract_datetime::=

 

YEAR

 

 

 

MONTH

 

 

 

DAY

 

 

 

HOUR

 

 

 

MINUTE

 

 

 

SECOND

 

datetime_value_expression

EXTRACT

(

FROM

)

 

TIMEZONE_HOUR

 

interval_value_expression

TIMEZONE_MINUTE

TIMEZONE_REGION

TIMEZONE_ABBR

Purpose

EXTRACT extracts and returns the value of a specified datetime field from a datetime or interval value expression. When you extract a TIMEZONE_REGION or TIMEZONE_ABBR (abbreviation), the value returned is a string containing the appropriate time zone name or abbreviation. When you extract any of the other values, the value returned is in the Gregorian calendar. When extracting from a datetime with a time zone value, the value returned is in UTC. For a listing of time zone names and their corresponding abbreviations, query the V$TIMEZONE_NAMES dynamic performance view.

Some combinations of datetime field and datetime or interval value expression result in ambiguity. In these cases, Oracle returns ’UNKNOWN’ (see the examples that follow for additional information).

Functions 6-63

EXTRACT (datetime)

Note: The field you are extracting must be a field of the datetime_value_expr or interval_value_expr. For example, you can extract only YEAR, MONTH, and DAY from a DATE value. Likewise, you can extract TIMEZONE_HOUR and TIMEZONE_ MINUTE only from the TIMESTAMP WITH TIME ZONE datatype.

See Also:

"Datetime/Interval Arithmetic" on page 2-25 for a description of datetime_value_expr and interval_value_expr

Oracle9i Database Reference for information on the dynamic performance views

Examples

The following example returns the year 1998.

SELECT EXTRACT(YEAR FROM DATE ’1998-03-07’) FROM DUAL;

EXTRACT(YEARFROMDATE’1998-03-07’)

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

1998

The following example selects from the sample table hr.employees all employees who were hired after 1998:

SELECT last_name, employee_id, hire_date

FROM employees

WHERE EXTRACT(YEAR FROM

TO_DATE(hire_date, ’DD-MON-RR’)) > 1998

ORDER BY hire_date;

LAST_NAME

EMPLOYEE_ID HIRE_DATE

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

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

Landry

127

14-JAN-99

Lorentz

107

07-FEB-99

Cabrio

187

07-FEB-99

.

 

 

.

 

 

.

 

 

The following example results in ambiguity, so Oracle returns ’UNKNOWN’:

6-64 Oracle9i SQL Reference

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