1. Trang chủ
  2. » Công Nghệ Thông Tin

Tài liệu Oracle Unleashed- P3 ppt

50 318 0
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Tiêu đề Oracle Unleashed
Trường học University of Oracle
Chuyên ngành Computer Science
Thể loại ang tập tài liệu
Định dạng
Số trang 50
Dung lượng 139,48 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

The following example from the order_total package illustrates numeric FOR loops: FOR i in 1..g_line_counter LOOP loop processing END LOOP recip_list; In this example, loop processin

Trang 1

a cursor parameter, whose value is set when the cursor opens, only during the cursor's declared SQL query

Flexibility within cursor parameters enables the developer to pass different numbers of parameters to a cursor by using the parameter default mechanism This is illustrated in the following example:

CURSOR c_line_item

(order_num INTEGER DEFAULT 100,

line_num INTEGER DEFAULT 1) IS

By using the INTEGER DEFAULT declaration, you can pass all, one, or none of the parameters to this cursor depending

on the logic flow of your code

Creating Cursor Packages

A cursor package is similar to a procedure package in that you specify the cursor and its return attribute, %TYPE or %ROWTYPE, in the package specification area You then specify the cursor "body" in the package body specification area Packaging a cursor in this manner gives you the flexibility of changing the cursor body without having to recompile applications that reference the packaged procedure The following is a cursor package example:

CREATE OR REPLACE PACKAGE order_total

Trang 2

follow the same rules Also, you can define variables and constants as local to one subprogram or global to the entire package you are creating

You must declare variables and constants before referencing them in any other statement

Variable Declaration and Assignment

Any PL/SQL or SQL data type is valid for variable definitions The most commonly used data types are VARCHAR2, DATE, NUMBER (SQL data types), BOOLEAN, and BINARY_INTEGER (PL/SQL data types) PL/SQL scalar and composite data types are discussed in more detail later in this chapter

Local Variables

Assume you want to declare two local variables named merch_gross and recip_count The first, merch_gross, is to hold a ten-digit, floating-point number rounded to two decimal places; recip_count will hold an integer counter Declare these variables as follows:

merch_gross NUMBER;

recip_count BINARY_INTEGER;

You can also declare merch_gross in this example as NUMBER(10,2) to explicitly show total digits and

rounding However, if it's related to a database field, a declaration of this type must change if the database definition changes

You can use two methods to assign values to variables The first is using an assignment operator as follows:

Trang 3

tax_rate CONSTANT NUMBER := 0.03;

Global Variables

Global variables are defined in the same manner as local variables, but they are defined outside of all procedure

definitions Suppose you want to define variables g_order_num and g_recip_counter to be available to all package

subprograms The following is an example of the syntax:

CREATE OR REPLACE PACKAGE BODY

Notice that these global variables are defined in the package body specification area so as not to be "seen" by

applications that call the order_total packaged procedure

If you use variable names that are the same as database column names, results are unpredictable when

performing any database operations such as SELECT or UPDATE with the variables

DEFAULT Keyword

The DEFAULT keyword enables you to initialize variables without using the assignment operator as in the following example:

merch_gross NUMBER DEFAULT 10.50;

You can also use the DEFAULT keyword to initialize a subprogram's cursor parameters and fields in user-defined records

Variable and Constant Attributes

The two attributes of PL/SQL variables and constants are %TYPE and %ROWTYPE The %TYPE attribute enables you

to declare variables similar to database columns without knowing the data type of the column You can define

merch_gross from the previous example as follows:

merch_gross line_item.merch_gross%TYPE;

Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.

Trang 4

Defining a variable in this manner enables you to put database changes in effect on the next compilation of a PL/SQL procedure without changing the code

The %ROWTYPE attribute enables you to represent a row in a table with a record type that masks the database columns Consider the sample database information in Table 5.1

Table 5.1 Sample of data in table LINE_ITEM.

Column Name Data

After the FETCH, use dot notation to access the information pulled from the database

g_order_merch_total := g_order_merch_total + li_info.merch_gross;

Scalar Data Types

PL/SQL supports a wide range of scalar data types for defining variables and constants Unlike composite data types, scalar data types have no accessible components These data types fall into one of the following categories:

Trang 5

Character

Character data types include CHAR, VARCHAR2, LONG, RAW, and LONG RAW CHAR is for fixed-length

character data, and VARCHAR2 stores variable-length character data LONG stores variable-length character strings; RAW and LONG RAW store binary data or byte strings The CHAR, VARCHAR2, and RAW data types take an optional parameter for specifying length

datatype(max_len)

This length parameter, max_len, must be an integer literal, not a constant or variable Table 5.2 shows maximum lengths and database column widths of character data types

Table 5.2 Character data type maximum lengths and database column widths.

Data Type Maximum Length Maximum Database Column Width

Trang 6

Number

There are two data types in the number data type category: BINARY_INTEGER and NUMBER BINARY_INTEGER stores signed integers with a range of -231 to 231-1 The most common use for this data type is an index for PL/SQL tables

Storage for fixed or floating-point numbers of any size is available using the NUMBER data type For floating-point numbers, you can specify precision and scale in the following format:

NUMBER(10,2)

A variable declared in this manner has a maximum of ten digits, and rounding occurs to two decimal places The precision default is the maximum integer supported by your system, and 0 is the default for scale The range for

precision is 1 to 38 whereas the scale range is -84 to 127

Composite Data Types

The two composite data types in PL/SQL are TABLE and RECORD The TABLE data type enables the user to define a PL/SQL table to be used for array processing The RECORD data type enables the user to go beyond the %ROWTYPE variable attribute; with it, you specify user-defined fields and field data types

Array Processing

The TABLE composite data type provides the developer a mechanism for array processing Although it's limited to one column of information per PL/SQL table, you can store any number of rows for that column The word from Oracle is that future versions of PL/SQL will provide more flexibility in the use of tables

In the order_total example, define a PL/SQL table named g_recip_list (the information will be used globally) The following is an illustration of this concept:

TYPE RecipientTabTyp IS TABLE OF NUMBER(22)

structure, you can make reference for variable definition as shown with g_recip_list defined as an array of TYPE

Trang 7

RecipientTabTyp

Building Arrays

Arrays are available as information stores subsequent to initialization of the array To store information in the array g_recip_list that was defined in the last example, you simply reference the array with a numeric value This is shown in the following example:

g_recip_list(j) := g_recipient_num(i)

In this example, i and j are counters with values 1 .n Once information is stored in an array, you can access it, also

with numeric values, as shown in the example In this case, rows of g_recipient_num are referenced for storage in g_recip_list

Referencing an uninitialized row in a PL/SQL array causes a NO_DATA_FOUND error (see the section

"Exception Handling" later in this chapter)

Defining a RECORD of TYPE LineRecTyp allows declarations such as li_info of that TYPE as shown You can use this

method of RECORD declaration in place of the li_info declaration in the previous %ROWTYPE example As with %

ROWTYPE, references to RECORD information is accomplished with dot notation

g_order_merch_total := g_order_merch_total + li_info.merch_gross;

You can use one of three methods to assign values to records First, you can assign a value to a record field as you would assign any variable

Trang 8

This statement assigns all fields of new_li_info the values from the same fields of li_info

You cannot assign records of different types to each other

A third method of assigning values to fields of a record is through SQL SELECT or FETCH statements

Every procedural language has control structures that provide processing of information in a logical manner by

controlling the flow of information Available structures within PL/SQL include IF-THEN-ELSE, LOOP, and WHEN These structures provide flexibility in manipulating database information

END LOOP loop_name;

To break out of a loop such as this, you must issue an EXIT or GOTO statement based on some processing condition If you raise a user-defined exception, the LOOP also terminates Now, examine three types of PL/SQL loops that expressly define LOOP termination conditions

You can name a loop as shown in the example by using a label such as <<loop_name>> just before the

LOOP statement Although it's not required, labeling does enable you to keep better track of nested loops

WHILE Loops

Trang 9

The WHILE loop checks the status of any PL/SQL expression that evaluates to TRUE, FALSE, or NULL at the start of each processing cycle The following is an example of the use of WHILE loops:

WHILE (expression) LOOP

(loop processing)

END LOOP;

As stated, the program evaluates the expression at the start of each loop cycle The program performs the loop

processing if the expression evaluates to TRUE A FALSE or NULL evaluation terminates the loop Iterations through the loop are exclusively determined by the evaluation of the expression

Numeric FOR Loops

You can control loop iterations with the use of numeric FOR loops This mechanism enables the developer to establish a range of integers for which the loop will cycle The following example from the order_total package illustrates numeric FOR loops:

<<recip_list>>

FOR i in 1 g_line_counter LOOP

(loop processing)

END LOOP recip_list;

In this example, loop processing cycles over the range of integers 1 through the value of g_line_counter The value of the loop index i is checked at the start of the loop and incremented at the end of the loop When i is one greater than

g_line_counter, the loop terminates

Cursor FOR Loops

Cursor FOR loops combine cursor control and conditional control for manipulation of database information The loop index, cursor OPEN, cursor FETCH, and cursor CLOSE are all implicit when using cursor FOR loops Consider the following example:

CURSOR c_line_item IS

(sql statement)

BEGIN

FOR li_info IN c_line_item LOOP

(retrieved record processing)

END LOOP;

END;

As shown, the program explicitly declares the c_line_item cursor before its reference in the FOR loop When the

program enters the FOR loop, the code implicitly opens c_line_item and implicitly creates the li_info record as if the Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.

Trang 10

following declaration were made:

li_info c_line_item%ROWTYPE;

Once inside the loop, the program can reference the fields of the li_info record that are assigned values by the implicit FETCH inside the FOR loop Fields of li_info mirror the row retrieved by the c_line_item cursor

When data is exhausted for the FETCH, c_line_item is implicitly closed

You cannot reference the information contained in li_info outside of the cursor FOR loop

Iterative Control

The IF-THEN-ELSE structure provides alternative processing paths that depend on certain conditions For example, consider merchandise orders with multiple-line items where a list of recipients is built Using conditional and iterative control to build the recipient list, the code is as follows:

Trang 11

IF g_recipient_num(i) = g_recip_list(k) THEN

Also illustrated in this example is the IF-THEN-ELSE extension ELSIF This statement provides further conditional control with additional constraint checks within the IF-THEN-ELSE structure Use of ELSIF also requires a THEN statement in executing logic control

Another example of iterative control is the use of the EXIT-WHEN statement that allows completion of a LOOP once certain conditions are met Consider the example of exiting a cursor fetch loop:

open c_line_item;

loop

fetch c_line_item

into li_info;

EXIT WHEN (c_line_item%NOTFOUND) or (c_line_item%NOTFOUND is NULL);

In this example, the LOOP is terminated when no more data is found to satisfy the select statement of cursor

c_line_item

Use of %NOTFOUND or %FOUND can cause infinite loops if you do not check for these attributes evaluating

to NULL on an EXIT-WHEN logical check

Exception Handling

Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.

Trang 12

PL/SQL exception handling is a mechanism for dealing with run-time errors encountered during procedure execution Use of this mechanism enables execution to continue if the error is not severe enough to cause procedure termination The decision to enable a procedure to continue after an error condition is one you have to make in development as you consider possible errors that could arise

You must define the exception handler within a subprogram specification Errors cause the program to raise an exception with a transfer of control to the exception-handler block After the exception handler executes, control returns to the block in which the handler was defined If there are no more executable statements in the block, control returns to the caller

User-Defined Exceptions

PL/SQL enables the user to define exception handlers in the declarations area of subprogram specifications You

accomplish this by naming an exception as in the following example:

ot_failure EXCEPTION;

In this case, the exception name is ot_failure Code associated with this handler is written in the EXCEPTION

specification area as follows:

Within this exception is the RAISE statement that transfers control back to the ot_failure exception handler This

technique of raising the exception is used to invoke all user-defined exceptions

Trang 13

Exception Name Oracle Error

out_msg := g_out_msg || ' ' || SUBSTR(SQLERRM, 1, 60);

This technique is used in the order_total sample procedure to trap all procedure errors other than NO_DATA_FOUND

The information passed back to the caller in out_msg is the subprogram name contained in g_out_msg concatenated with

the first 60 characters returned from the SQLERRM function by the SUBSTR function

Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.

Trang 14

Both SQLERRM and SUBSTR are internal PL/SQL functions You can find a complete list of internal functions later in this chapter

SQLERRM only returns a valid message when called inside an exception handler unless an argument is passed to the function that is a valid SQL error number The Oracle error code is the first part of the message returned from

SQLERRM Next is the text associated with that Oracle error code

In this manner, all errors encountered during procedure execution are trapped and passed back to the application for debug purposes The following is a sample return error from the order_total procedure:

FAIL: init_line_items ORA-01001: invalid cursor

This error message (formatted by the application) reveals an illegal cursor operation in the subprogram init_line_items The portion of the message returned from SQLERRM begins with the ORA-01001 SQL error code Another error message is illustrated in the following example:

*************** CREATE PACKAGE ORDER_TOTALING ***************

A double dash at the start of the line marks the line as a comment The second method is used to place a sequence of comment statements in a PL/SQL package

/* The following code generates a list of unique recipient

numbers from all recipient numbers for a particular order */

A comment block such as this begins with the /* and ends with the */ You can place single-line and multiple-line comments in any portion of PL/SQL code

PL/SQL blocks that are dynamically compiled in Oracle Precompiler applications do not support use of line comments

Trang 15

single-Stored Procedures

You can store PL/SQL code in the Oracle database with the RDBMS Procedural Database Extension Advantages of using stored procedures include easier maintenance, decreased application size, increased execution speed, and greater memory savings, to name a few With this in mind, explore the various techniques for accessing stored procedures in the following sections

Referencing Stored Procedures

Another big advantage to using stored procedures is the capability to reference the procedure from many different Oracle applications You can make reference to stored procedures with other stored procedures, database triggers, applications built with Oracle Precompilers, or Oracle tools such as SQL*Forms The following example calls the order_total

procedure from another procedure:

All parameters in this example to the order_total procedure are Oracle bind variables that you must declare before the

reference to the package The final example illustrates a call to the order_total package from a SQL*Forms application Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.

Trang 16

Once again, you must declare all variables passed as parameters before calling the procedure

Calling stored procedures with COMMIT, ROLLBACK, or SAVEPOINT statements from SQL*Forms is prohibited and is discussed later in this chapter

Stored Procedure States

After compilation, a stored procedure exists in either a valid or invalid state If you haven't made any changes to the

procedure, it is considered valid and may be referenced If any subprogram or object referenced within a procedure changes, its state becomes invalid Only procedures in a valid state are available for reference

Referencing a procedure that is invalid causes Oracle to recompile any and all objects called by the referenced

procedure If the recompilation does not succeed, Oracle returns a run-time error to the caller, and the procedure remains

in an invalid state Otherwise, Oracle recompiles the referenced procedure, and if the recompilation is successful, execution continues

Stored procedures are located in the Oracle SGA after compilation If the SGA is too small for the user base, the procedure might be swapped out and become invalid with no indication to the caller The first reference to the procedure after it is swapped out causes a recompilation, returning it to a valid state

Overloading

The concept of overloading in PL/SQL relates to the idea that you can define procedures and functions with the same

Trang 17

name PL/SQL does not look only at the referenced name, however, to resolve a procedure or function call The count and data types of formal parameters are also considered

PL/SQL also attempts to resolve any procedure or function calls in locally defined packages before looking at globally defined packages or internal functions To further ensure calling the proper procedure, you can use the dot notation as illustrated by previous examples on application references to stored procedures Prefacing a procedure or function name with the package name fully qualifies any procedure or function reference

SESSION statement and subsequently call the procedure The following is an example of calling the order_total

procedure from SQL*Forms through a user exit:

user_exit('order_totl');

In this case, the order_totl routine of the SQL*Forms user exit references the order_total packaged procedure

Issuing a COMMIT from a PL/SQL procedure that is called from SQL*Forms attempts to commit any changes from the forms application as well

Package STANDARD

PL/SQL provides various tools in a package named STANDARD for use by developers These tools include internal functions and internal exceptions I previously discussed exception handling and two internal functions, SQLCODE and SQLERRM, that provide information for exception reporting and are only valid in exception handlers

Referencing Internal Functions

Internal PL/SQL functions exemplify the concept of overloading with respect to naming procedures and functions Remember that PL/SQL resolves a procedure or function call by matching the number and data types of formal

parameters in the reference and not just by reference name Consider the two internal functions named TO_NUMBER in the following example:

function TO_NUMBER (str CHAR [, fmt VARCHAR2, [, nlsparms] ]) return NUMBER

function TO_NUMBER (str VARCHAR2 [, fmt VARCHAR2 [, nlsparms] ]) return NUMBER

Both functions are named TO_NUMBER, but the data type of the first parameter is CHAR in the first definition and VARCHAR2 in the second Optional parameters are the same in both cases PL/SQL resolves a call to the

TO_NUMBER function by looking at the data type of the first parameter

You might also have a user-defined procedure or function named TO_NUMBER In this case, the local definition takes precedence over the internal function definition You can still access the internal function, however, by using the dot notation as follows:

Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.

Trang 18

Table 5.4 Internal function categories and common return values.

Category Common Return Value

function ASCII (char VARCHAR2) return VARCHAR2

Table 5.5 Character functions.

ASCII Returns standard collating code for

CHR Returns character for collating code num NUMBER

Trang 19

CONCAT Returns str2 appended to str1 str1 VARCHAR2, str2 VARCHAR2

INITCAP

Returns str1 with the first letter of each

word in uppercase and all others in lowercase

str1 VARCHAR2

INSTR

Returns starting position of str2 in str1

Search begins at pos for the nth occurrence

If pos is negative, the search is performed backwards Both pos and n default to 1

The function returns 0 if str2 is not found.

str1 VARCHAR2, str2 VARCHAR2 [, pos NUMBER [, n NUMBER]]

INSTRB Similar to INSTR except pos is a byte

position

str1 VARCHAR2, str2 VARCHAR2 [, pos NUMBER [, n NUMBER]]

LENGTH Returns character count in str and for data

type CHAR; length includes trailing blanks

str CHAR or

LENGTHB Similar to LENGTH; returns byte count of

str including trailing blanks for CHAR.

LPAD

Left pads str to length len with characters

in pad, which defaults to a single blank

Returns first len characters in str if str is longer than len.

str VARCHAR2 len NUMBER [, pad VARCHAR2]

NLS_INITCAP Similar to INITCAP except a sort sequence

is specified by nlsparms.

str VARCHAR2 [, nlsparms VARCHAR2]

NLS_LOWER Similar to LOWER except a sort sequence

is specified by nlsparms.

str VARCHAR2 [, nlsparms VARCHAR2]

NLS_UPPER Similar to UPPER except a sort sequence is

specified by nlsparms.

str VARCHAR2 [, nlsparms VARCHAR2]

NLSSORT Returns str in sort sequence specified by

nlsparms.

str VARCHAR2

Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.

Trang 20

RPAD Similar to LPAD except str is right padded

with len sequence of characters in pad.

str VARCHAR2, len VARCHAR2, [, pad VARCHAR2]

NUMBER

RTRIM

Similar to LTRIM except trailing

characters are removed from str after the first character not in set.

str VARCHAR2 [, set VARCHAR2]

SOUNDEX Returns phonetic representation of str. str VARCHAR2

SUBSTR

Returns substring of str starting at pos for length len or to the end of str if len is omitted For pos < 0, SUBSTR counts backward from the end of str.

str VARCHAR2, pos NUMBER [, len NUMBER]

SUBSTRB Similar to SUBSTR except works on bytes,

not characters

str VARCHAR2, pos NUMBER [, len NUMBER]

TRANSLATE Replaces all occurrences of set1 with set2

characters in str.

str VARCHAR2, set1 VARCHAR2, set2 CHAR

UPPER Returns all letters in uppercase str CHAR or

str VARCHAR2

Conversion Functions

Table 5.6 lists available conversion functions along with a brief description, argument list, and return value Optional arguments are enclosed in square brackets All internal conversion functions are of the following form:

function CHARTOROWID (str VARCHAR2) return ROWID

Table 5.6 Conversion functions.

str VARCHAR2 ROWID

Trang 21

Converts str from character set1 to character set2

Character set1 and set2 can be a character set

name or database column

str VARCHAR2, set1 VARCHAR2, set2 VARCHAR2

VARCHAR2

HEXTORAW Converts str from CHAR or VARCHAR2 to

RAW

str CHAR or str VARCHAR2 RAW

ROWIDTOCHAR Converts bin from ROWID to 18-byte hex string bin ROWID VARCHAR2

TO_CHAR (Dates)

Converts dte to VARCHAR2 based on fmt You

can specify a language for date conversion in

nlsparms.

dte DATE [, fmt VARCHAR2 [, nlsparms] ]

VARCHAR2

TO_CHAR (Numbers)

Converts num to VARCHAR2 based on fmt You

can specify the following format elements in

nlsparms: decimal character, group separator,

and a symbol for local or international currency

num NUMBER [, fmt VARCHAR2 [, nlsparms] ]

VARCHAR2

TO_CHAR (Labels) Converts MLSLABEL type to VARCHAR2

based on fmt.

label [, fmt VARCHAR2] VARCHAR2

TO_DATE

Converts str or num to DATE value based on fmt

The fmt argument is not optional when

converting a number You can specify a language

for date conversion in nlsparms.

str VARCHAR2 or num NUMBER [,nlsparms]

MLSLABEL

TO_MULTI_BYTE Converts single-byte str to multi-byte equivalent,

if it exists

str CHAR str VARCHAR2 CHAR VARCHAR2

TO_NUMBER

Converts str to NUMBER value according to fmt

You can specify format elements in nlsparms as

described in the TO_CHAR function

str CHAR str VARCHAR2 NUMBER NUMBER

str VARCHAR2 CHAR VARCHAR2

Date Functions

All date functions return a DATE value unless otherwise specified in Table 5.7, which lists available date functions along with a brief description, argument list, and return value Optional arguments are enclosed in square brackets All Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.

Trang 22

internal date functions are of the following form:

function ADD_MONTHS (dte DATE, num NUMBER) return DATE

Table 5.7 Date functions.

ADD_MONTHS Returns dte plus or minus num months dte DATE,

num NUMBER

MONTHS_BETWEEN Returns month count between dte1 and dte2

NUMBER is < 0 if dte1 is earlier than dte2.

dte1 DATE,

NEW_TIME Returns date and time in zon2 based on dte date and

time in time zone zon1.

dte DATE, zon1

VARCHAR2

ROUND Returns dte rounded to specified unit in fmt If no

fmt is specified, dte is rounded to the the nearest day.

dte DATE [, fmt VARCHAR2]

TRUNC Returns dte with the time of day truncated as

specified by fmt.

dte DATE [, fmt VARCHAR2]

Miscellaneous Functions

Table 5.8 lists miscellaneous functions along with a brief description, argument list, and return value Optional

arguments are enclosed in square brackets

Table 5.8 Miscellaneous functions.

Trang 23

Returns internal

representation of expr based

on one of the following fmt

specifications:

expr DATE or expr NUMBER or expr VARCHAR2

VARCHAR2

16=hexadecimal [, len BINARY_INTEGER]]]

17=single character

Arguments pos and len

specify the portion of the representation to return

GREATEST

Returns greatest value of list

of exprn All expressions

must be data-type compatible

with expr1.

expr1, expr2, expr3

GREATEST_LB

Returns greatest lower bound

from list of labels Each label

must be of type MLSLABEL

GREATEST_LB is a Trusted Oracle function

LEAST

Returns least value from list

of exprn All expressions

must be data-type compatible

with expr1.

expr1, expr2, expr3

LEAST_UB

Returns least upper bound

from list of of labels Each label must be of type

MLSLABEL LEAST_UB is

a Trusted Oracle function

NVL

Returns value of not null

arg1 or value of arg2 arg1 and arg2 must be of the same

data type

UID Returns unique ID number of

Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.

Trang 24

USER Returns username of current

'LANGUAGE' language, territory, and database

character set

'SESSIONID' auditing session identifier

VSIZE Returns number of bytes in

expr.

expr DATE or expr NUMBER or

Number Functions

All number functions return a NUMBER value unless otherwise specified in Table 5.9, which lists available number functions along with a brief description, argument list, and return value Optional arguments are enclosed in square brackets All internal number functions are of the following form:

function ABS (n NUMBER) return NUMBER

Table 5.9 Number functions.

COS Returns cosine of a Angle a must be in radians a NUMBER

Trang 25

COSH Returns hyperbolic cosine of n n NUMBER

LN Returns natural log of n where n > 0 n NUMBER

LOG Returns base-m log of n where m > 1 and n > 0 m NUMBER,

SIGN Returns -1 for n < 0, 0 for n=0 and 1 for n > 0 n NUMBER

SIN Returns sine of a Angle a must be in radians a NUMBER

TAN Returns tangent of a Angle a must be in radians a NUMBER

[, n NUMBER]

Additional Topics

There are a few more areas of PL/SQL that I would like discuss for the sake of

completeness These topics have relevance to the general understanding of the PL/SQL language and should be reviewed

DECLARE Statement

Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.

Ngày đăng: 26/01/2014, 15:20

TỪ KHÓA LIÊN QUAN