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

SYS_DBURIGEN

Table 6–2 (Cont.) Predefined Parameters of Namespace USERENV

 

 

Return

 

 

Length

Parameter

Return Value

(bytes)

 

 

 

SESSIONID

The auditing session identifier. You cannot use this

30

 

attribute in distributed SQL statements.

 

 

 

 

TERMINAL

The operating system identifier for the client of the

10

 

current session. In distributed SQL statements, this

 

 

attribute returns the identifier for your local session.

 

 

In a distributed environment, this is supported only

 

 

for remote SELECT statements, not for remote

 

 

INSERT, UPDATE, or DELETE operations. (The return

 

 

length of this parameter may vary by operating

 

 

system.)

 

 

 

 

SYS_DBURIGEN

Syntax sys_dburigen::=

 

 

,

 

 

 

 

 

 

 

column

rowid

,

text

(

)

SYS_DBURIGEN

(

 

 

 

 

 

 

)

 

attribute

 

 

 

 

 

 

 

Purpose

SYS_DBURIGen takes as its argument one or more columns or attributes, and optionally a rowid, and generates a URL of datatype DBURIType to a particular column or row object. You can then use the URL to retrieve an XML document from the database.

All columns or attributes referenced must reside in the same table. They must perform the function of a primary key. That is, they need not actually match the primary keys of the table, but they must reference a unique value. If you specify multiple columns, then all but the final column identify the row in the database, and the last column specified identifies the column within the row.

By default the URL points to a formatted XML document. If you want the URL to point only to the text of the document, then specify the optional ’text()’. (In this XML context, the lowercase ’text’ is a keyword, not a syntactic placeholder.)

Functions 6-161

SYS_EXTRACT_UTC

If the table or view containing the columns or attributes does not have a schema specified in the context of the query, then Oracle interprets the table or view name as a public synonym.

See Also: Oracle9i XML API Reference - XDK and Oracle XML DB and Oracle9i XML Developer’s Kits Guide - XDK for information on the URIType datatype and XML documents in the database

Examples

The following example uses the SYS_DBURIGen function to generate a URL of datatype DBURIType to the email column of the row in the sample table hr.employees where the employee_id = 206:

SELECT SYS_DBURIGEN(employee_id, email)

FROM employees

WHERE employee_id = 206;

SYS_DBURIGEN(EMPLOYEE_ID,EMAIL)(URL, SPARE)

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

DBURITYPE(’/PUBLIC/EMPLOYEES/ROW[EMPLOYEE_ID=’’206’’]/EMAIL’, NULL)

SYS_EXTRACT_UTC

Syntax sys_extract_utc::=

SYS_EXTRACT_UTC ( datetime_with_timezone )

Purpose

SYS_EXTRACT_UTC extracts the UTC (Coordinated Universal Time—formerly Greenwich Mean Time) from a datetime with time zone displacement.

Examples

The following example extracts the UTC from a specified datetime:

SELECT SYS_EXTRACT_UTC(TIMESTAMP ’2000-03-28 11:30:00.00 -08:00’) FROM DUAL;

SYS_EXTRACT_UTC(TIMESTAMP’2000-03-2811:30:00.00-08:00’)

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

28-MAR-00 07.30.00 PM

6-162 Oracle9i SQL Reference

SYS_GUID

SYS_GUID

Syntax sys_guid::=

SYS_GUID ( )

Purpose

SYS_GUID generates and returns a globally unique identifier (RAW value) made up of 16 bytes. On most platforms, the generated identifier consists of a host identifier and a process or thread identifier of the process or thread invoking the function, and a nonrepeating value (sequence of bytes) for that process or thread.

Examples

The following example adds a column to the sample table hr.locations, inserts unique identifiers into each row, and returns the 32-character hexadecimal representation of the 16-byte RAW value of the global unique identifier:

ALTER TABLE locations ADD (uid_col RAW(32));

UPDATE locations SET uid_col = SYS_GUID();

SELECT location_id, uid_col FROM locations;

LOCATION_ID

UID_COL

-----------

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

1000

7CD5B7769DF75CEFE034080020825436

1100

7CD5B7769DF85CEFE034080020825436

1200

7CD5B7769DF95CEFE034080020825436

1300

7CD5B7769DFA5CEFE034080020825436

.

 

.

 

.

 

Functions 6-163

SYS_TYPEID

SYS_TYPEID

Syntax sys_typeid::=

SYS_TYPEID ( object_type_value )

Purpose

SYS_TYPEID returns the typeid of the most specific type of the operand. This value is used primarily to identify the type-discriminant column underlying a substitutable column. For example, you can use the value returned by SYS_TYPEID to build an index on the type-discriminant column.

Notes:

Use this function only on object type operands.

All final root object types—that is, final types not belonging to a type hierarchy—have a null typeid. Oracle assigns to all types belonging to a type hierarchy a unique non-null typeid.

See Also: Oracle9i Application Developer’s Guide - Object-Relational Features for more information on typeids

Examples

The following examples use the tables persons and books, which are created in "Substitutable Table and Column Examples" on page 15-67. Both tables in turn use the person_t type, which is created in "Type Hierarchy Example" on page 16-22. The first query returns the most specific types of the object instances stored in the persons table.

SELECT name, SYS_TYPEID(VALUE(p)) "Type_id" FROM persons p;

NAME

Type_id

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

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

Bob

01

Joe

02

Tim

03

The next query returns the most specific types of authors stored in the table books:

6-164 Oracle9i SQL Reference

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