Functions

来源:互联网 发布:java 余弦相似度算法 编辑:程序博客网 时间:2024/05/16 07:48

Functions are similar to operators in that they manipulate data items(操作数据项) and return a result.
Functions differ from operators in the format of their arguments(函数的参数格式与运算符不同。).
This format enables them to operate on zero, one, two, or more arguments:
function(argument, argument, …)

A function without any arguments is similar to a pseudocolumn(伪列) (refer to Chapter 3, “Pseudocolumns”).
However, a pseudocolumn typically returns a different value for each row in the result set, whereas a function without any arguments typically returns the same value for each row.
This chapter contains these sections:

About SQL Functions
SQL functions are built into Oracle Database and are available for use in various appropriate(各种适当的) SQL statements.
Do not confuse(混淆) SQL functions with user-defined functions written in PL/SQL.
If you call a SQL function with an argument of a data type other than the data type expected by the SQL function, then Oracle attempts to convert the argument to the expected data type before performing the SQL function.

Nulls in SQL Functions Most scalar functions(标量函数) return null when given a null argument.
You can use the NVL function to return a value when a null occurs.
For example, the expression NVL(commission_pct,0) returns 0 if commission_pct is null or the value of commission_pct if it is not null.

Syntax for SQL Functions
In the syntax diagrams(语法图) for SQL functions, arguments are indicated by their data types.
When the parameter function appears in SQL syntax, replace it with one of the functions described in this section. Functions are grouped by the data types of their arguments and their return values.

Note: When you apply SQL functions to LOB columns, Oracle Database creates temporary LOBs during SQL and PL/SQL processing.
You should ensure that temporary tablespace quota is
sufficient(充足的) for storing these temporary LOBs for your application.

Note: The combined values of the NLS_COMP and NLS_SORT settings determine the rules by which characters are sorted and compared.
If NLS_COMP is set to LINGUISTIC for your database, then all entities in this chapter will be interpreted (解释)according(根据) to the rules specified by the NLS_SORT parameter.
If NLS_COMP is not set to LINGUISTIC, then the functions are interpreted without regard(看待) to the NLS_SORT setting.
NLS_SORT can be explicitly (显式的)set.
If it is not set explicitly, it is derived(有 … 决定) from NLS_LANGUAGE.
Refer to Oracle Database Globalization Support Guide for more information on these settings.
The syntax showing the categories(分类) of functions follows:
这里写图片描述
这里写图片描述

The sections that follow list the built-in(内置) SQL functions in each of the groups illustrated in the preceding diagrams(之前的图) except user-defined functions.
All of the built-in SQL functions are then described in alphabetical order(字母顺序).

Single-Row Functions
Single-row functions return a single result row for every row of a queried table or view.
These functions can appear in select lists, WHERE clauses, START WITH and CONNECT BY clauses, and HAVING clauses.

Numeric Functions
Numeric functions accept numeric input and return numeric values.
Most numeric functions return NUMBER values that are accurate to 38 decimal digits(精确到38个小数位数). The transcendental functions(先验函数) COS, COSH, EXP, LN, LOG, SIN, SINH, SQRT, TAN, and TANH are
accurate to 36 decimal digits.
The transcendental functions ACOS, ASIN, ATAN, and ATAN2
are accurate to 30 decimal digits.
The numeric functions are:

0 0
原创粉丝点击