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

CREATE OPERATOR

CREATE OPERATOR

Purpose

Use the CREATE OPERATOR statement to create a new operator and define its bindings.

Operators can be referenced by indextypes and by DML and query SQL statements. The operators, in turn, reference functions, packages, types, and other user-defined objects.

See Also: Oracle9i Data Cartridge Developer’s Guide and Oracle9i Database Concepts for a discussion of these dependencies and of operators in general

Prerequisites

To create an operator in your own schema, you must have CREATE OPERATOR system privilege. To create an operator in another schema, you must have the CREATE ANY OPERATOR system privilege. In either case, you must also have EXECUTE privilege on the functions and operators referenced.

Syntax

create_operator::=

OR

REPLACE

schema

.

 

 

CREATE

 

OPERAT0R

operator

binding_clause

;

binding_clause::=

 

 

 

 

,

 

 

 

 

,

 

 

 

 

BINDING

(

parameter_type

)

RETURN

return_type

implementation_clause

14-44 Oracle9i SQL Reference

CREATE OPERATOR

implementation_clause::=

 

 

 

 

 

,

 

 

 

 

 

 

,

 

ANCILLARY

TO

primary_operator

(

parameter_type

)

 

 

COMPUTE

ANCILLARY

DATA

 

context_clause

 

 

 

 

 

 

using_function_clause

context_clause::=

WITH INDEX CONTEXT , SCAN CONTEXT implementation_type

using_function_clause::=

 

 

package

.

schema

.

type

.

USING

 

 

function_name

Semantics

OR REPLACE

Specify OR REPLACE to replace the definition of the operator schema object.

Restriction on Replacing an Operator You can replace the definition only if the operator has no dependent objects (for example, indextypes supporting the operator).

schema

Specify the schema containing the operator. If you omit schema, Oracle creates the operator in your own schema.

operator

Specify the name of the operator to be created.

SQL Statements: CREATE LIBRARY to CREATE SPFILE 14-45

CREATE OPERATOR

binding_clause

Use the binding_clause to specify one or more parameter datatypes (parameter_type) for binding the operator to a function. The signature of each binding (that is, the sequence of the datatypes of the arguments to the corresponding function) must be unique according to the rules of overloading.

The parameter_type can itself be an object type. If it is, you can optionally qualify it with its schema.

Restriction on Binding Operators You cannot specify a parameter_type of REF,

LONG, or LONG RAW.

See Also: PL/SQL User’s Guide and Reference for more information about overloading

RETURN Clause

Specify the return datatype for the binding.

The return_type can itself be an object type. If so, you can optionally qualify it with its schema.

Restriction on Binding Return Datatype You cannot specify a return_type of

REF, LONG, or LONG RAW.

implementation_clause

ANCILLARY TO Clause

Use the ANCILLARY TO clause to indicate that the operator binding is ancillary to the specified primary operator binding (primary_operator). If you specify this clause, do not specify a previous binding with just one number parameter.

context_clause

Use the context_clause to specify the name of the implementation type used by the functional implementation of the operator as a scan context.

COMPUTE ANCILLARY DATA Specify COMPUTE ANCILLARY DATA to indicate that the operator binding computes ancillary data.

14-46 Oracle9i SQL Reference

CREATE OPERATOR

using_function_clause

The using_function_clause lets you specify the function that provides the implementation for the binding. function_name can be a standalone function, packaged function, type method, or a synonym for any of these.

Example

Creating User-Defined Operators: Example This example creates a very simple functional implementation of equality and then creates an operator that uses the function:

CREATE FUNCTION eq_f(a VARCHAR2, b VARCHAR2) RETURN NUMBER AS BEGIN

IF a = b THEN RETURN 1; ELSE RETURN 0;

END IF; END;

/

CREATE OPERATOR eq_op

BINDING (VARCHAR2, VARCHAR2)

RETURN NUMBER

USING eq_f;

SQL Statements: CREATE LIBRARY to CREATE SPFILE 14-47

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