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

ATAN2

ATAN

Syntax atan::=

ATAN ( n )

Purpose

ATAN returns the arc tangent of n. The argument n can be in an unbounded range, and the function returns values in the range of -π/2 to π/2 and are expressed in radians.

Examples

The following example returns the arc tangent of .3:

SELECT ATAN(.3) "Arc_Tangent" FROM DUAL;

Arc_Tangent

----------

.291456794

ATAN2

Syntax atan2::=

 

 

 

,

 

ATAN2

(

n

m

)

 

 

 

/

 

Purpose

ATAN2 returns the arc tangent of n and m. The argument n can be in an unbounded range, and the function returns values in the range of -π to π, depending on the signs of n and m, and are expressed in radians. ATAN2(n,m) is the same as

ATAN2(n/m)

Examples

The following example returns the arc tangent of .3 and .2:

Functions 6-21

AVG

SELECT ATAN2(.3, .2) "Arc_Tangent2" FROM DUAL;

Arc_Tangent2

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

.982793723

AVG

Syntax avg::=

 

DISTINCT

 

 

 

 

 

 

ALL

 

OVER

(

analytic_clause

)

AVG

(

expr

)

 

 

 

See Also: "Analytic Functions" on page 6-10 for information on syntax, semantics, and restrictions

Purpose

AVG returns average value of expr. You can use it as an aggregate or analytic function.

If you specify DISTINCT, then you can specify only the query_partition_ clause of the analytic_clause. The order_by_clause and windowing_ clause are not allowed.

See Also:

"Aggregate Functions" on page 6-8

"About SQL Expressions" on page 4-2 for information on valid forms of expr

Aggregate Example

The following example calculates the average salary of all employees in the hr.employees table:

SELECT AVG(salary) "Average" FROM employees;

6-22 Oracle9i SQL Reference

BFILENAME

Average

--------

6425

Analytic Example

The following example calculates, for each employee in the employees table, the average salary of the employees reporting to the same manager who were hired in the range just before through just after the employee:

SELECT manager_id, last_name, hire_date, salary,

AVG(salary) OVER (PARTITION BY manager_id ORDER BY hire_date ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) AS c_mavg

FROM employees;

MANAGER_ID

LAST_NAME

HIRE_DATE

SALARY

C_MAVG

----------

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

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

100

Kochhar

21-SEP-89

17000

17000

100

De Haan

13-JAN-93

17000

15000

100

Raphaely

07-DEC-94

11000

11966.6667

100

Kaufling

01-MAY-95

7900

10633.3333

100

Hartstein

17-FEB-96

13000

9633.33333

100

Weiss

18-JUL-96

8000

11666.6667

100

Russell

01-OCT-96

14000

11833.3333

.

 

 

 

 

.

 

 

 

 

.

 

 

 

 

BFILENAME

Syntax bfilename::=

BFILENAME ( directory , filename )

Purpose

BFILENAME returns a BFILE locator that is associated with a physical LOB binary file on the server’s file system.

directory’ is a database object that serves as an alias for a full path name on the server’s file system where the files are actually located

filename’ is the name of the file in the server’s file system

Functions 6-23

BFILENAME

You must create the directory object and associate a BFILE value with a physical file before you can use them as arguments to BFILENAME in a SQL or PL/SQL statement, DBMS_LOB package, or OCI operation.

You can use this function in two ways:

In a DML statement to initialize a BFILE column

In a programmatic interface to access BFILE data by assigning a value to the BFILE locator.

The directory argument is case sensitive. That is, you must ensure that you specify the directory object name exactly as it exists in the data dictionary. For example, if an "Admin" directory object was created using mixed case and a quoted identifier in the CREATE DIRECTORY statement, then when using the BFILENAME function you must refer to the directory object as ’Admin’. You must specify the filename argument according to the case and punctuation conventions for your operating system.

See Also:

Oracle9i Application Developer’s Guide - Large Objects (LOBs) and Oracle Call Interface Programmer’s Guide for more information on LOBs and for examples of retrieving BFILE data

CREATE DIRECTORY on page 13-49

Examples

The following example inserts a row into the sample table pm.print_media. The example uses the BFILENAME function to identify a binary file on the server’s file system:

CREATE DIRECTORY media_dir AS ’/demo/schema/product_media’;

INSERT INTO print_media (product_id, ad_id, ad_graphic) VALUES (3000, 31001,

bfilename(’MEDIA_DIR’, ’modem_comp_ad.gif’));

6-24 Oracle9i SQL Reference

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