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

DEPTH

DEPTH

Syntax depth::=

DEPTH ( correlation_integer )

Purpose

DEPTH is an ancillary function used only with the UNDER_PATH and EQUALS_PATH conditions. It returns the number of levels in the path specified by the UNDER_PATH condition with the same correlation variable.

The correlation_integer can be any integer. Use it to correlate this ancillary function with its primary condition if the statement contains multiple primary conditions. Values less than 1 are treated as 1.

See Also:

EQUALS_PATH on page 5-13, UNDER_PATH on page 5-20

the related function PATH on page 6-115

Examples

The EQUALS_PATH and UNDER_PATH conditions can take two ancillary functions, one of which is DEPTH. The following example shows the use of both ancillary functions. The example assumes the existence of the XMLSchema warehouses.xsd (created in "Using XML in SQL Statements" on page D-11).

SELECT PATH(1), DEPTH(2)

FROM RESOURCE_VIEW

WHERE UNDER_PATH(res, ’/sys/schemas/OE’, 1)=1

AND UNDER_PATH(res, ’/sys/schemas/OE’, 2)=1;

PATH(1)

DEPTH(2)

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

--------

/www.oracle.com

1

/www.oracle.com/xwarehouses.xsd

2

Functions 6-57

DEREF

DEREF

Syntax deref::=

DEREF ( expr )

Purpose

DEREF returns the object reference of argument expr, where expr must return a REF to an object. If you do not use this function in a query, then Oracle returns the object ID of the REF instead, as shown in the example that follows.

See Also: MAKE_REF on page 6-94

Examples

The sample schema oe contains an object type cust_address_typ (its creation is duplicated in the example that follows). The following example creates a table of cust_address_typ_new, and another table with one column that is a REF to cust_address_typ:

CREATE TYPE cust_address_typ_new AS OBJECT

( street_address

VARCHAR2(40)

, postal_code

VARCHAR2(10)

, city

VARCHAR2(30)

, state_province

VARCHAR2(10)

, country_id

CHAR(2)

);

 

/

CREATE TABLE address_table OF cust_address_typ_new;

CREATE TABLE customer_addresses ( add_id NUMBER,

address REF cust_address_typ_new SCOPE IS address_table);

INSERT INTO address_table VALUES

(’1 First’, ’G45 EU8’, ’Paris’, ’CA’, ’US’);

INSERT INTO customer_addresses

SELECT 999, REF(a) FROM address_table a;

SELECT address FROM customer_addresses;

6-58 Oracle9i SQL Reference

DUMP

ADDRESS

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

000022020876B2245DBE325C5FE03400400B40DCB176B2245DBE305C5FE03400400B40DCB1

SELECT DEREF(address) FROM customer_addresses;

DEREF(ADDRESS)(STREET_ADDRESS, POSTAL_CODE, CITY, STATE_PROVINCE, COUNTRY_ID)

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

CUST_ADDRESS_TYP(’1 First’, ’G45 EU8’, ’Paris’, ’CA’, ’US’)

DUMP

Syntax dump::=

 

 

 

 

,

length

 

 

 

,

start_position

 

 

 

,

return_fmt

 

 

DUMP

(

expr

 

 

)

Purpose

DUMP returns a VARCHAR2 value containing the datatype code, length in bytes, and internal representation of expr. The returned result is always in the database character set. For the datatype corresponding to each code, see Table 2–1 on

page 2-7.

The argument return_fmt specifies the format of the return value and can have any of the following values:

8 returns result in octal notation.

10 returns result in decimal notation.

16 returns result in hexadecimal notation.

17 returns result as single characters.

By default, the return value contains no character set information. To retrieve the character set name of expr, specify any of the preceding format values, plus 1000. For example, a return_fmt of 1008 returns the result in octal, plus provides the character set name of expr.

Functions 6-59

DUMP

The arguments start_position and length combine to determine which portion of the internal representation to return. The default is to return the entire internal representation in decimal notation.

If expr is null, then this function returns a null.

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.

Examples

The following examples show how to extract dump information from a string expression and a column:

SELECT DUMP(’abc’, 1016)

FROM DUAL;

DUMP(’ABC’,1016)

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

Typ=96 Len=3 CharacterSet=WE8DEC: 61,62,63

SELECT DUMP(last_name, 8, 3, 2) "OCTAL"

FROM employees

WHERE last_name = ’Hunold’;

OCTAL

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

Typ=1 Len=6: 156,157

SELECT DUMP(last_name, 10, 3, 2) "ASCII"

FROM employees

WHERE last_name = ’Hunold’;

ASCII

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

Typ=1 Len=6: 110,111

6-60 Oracle9i SQL Reference

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