1.3 Built-in PackagesPL/SQL packages allow you to collect related program elements and control access to those elements. Oracle provides a rich set of built-in packages that extend the functionality of PL/SQL in many important ways. Many of the built-ins allow you access to features that would otherwise be unavailable to you. You will find these packages helpful in developing applications, managing server-side resources, and performing many other operations. The built-in packages are listed in this section in alphabetical order. For each package, we've shown the header (calling sequence) for each of the programs defined in the package, and provided a brief description of the program operation. There are two default packages that deserve special mention. The STANDARD package contains many of the basic elements of the PL/SQL language (datatypes, functions, even basic operations like + and -). We describe the STANDARD functions later, in the Section 1.4, "Built-in Functions " section. The DBMS_STANDARD package, described in this section, contains kernel extensions to the STANDARD package. 1.3.1 DBMS_ALERTDBMS_ALERT provides mechanisms for synchronous, transaction-based notification to multiple sessions that specific database events have occurred.
Registers the calling session to receive notification of alert name .
Unregisters the calling session from receiving notification of alert name . PROCEDURE DBMS_ALERT.REMOVEALL; Unregisters the calling session from notification of all alerts.
Defines configurable settings for the calling session. ( sensitivity defines the loop interval sleep time in seconds.)
Signals the occurrence of alert name and attaches message . (Sessions registered for alert name are notified only when the signaling transaction commits.)
Waits for up to timeout seconds to be notified of any alerts for which the session is registered. If status = 0 then name and message contain alert information. If status = 1 then timeout seconds elapsed without notification of any alert.
Waits for up to timeout seconds for notification of alert name . If status = 0 then message contains alert information. If status = 1 then timeout seconds elapsed without notification. 1.3.2 DBMS_APPLICATION_INFODBMS_APPLICATION_INFO allows applications to register their current execution status into several of the Oracle V$ virtual tables.
Returns the currently registered client_info for the session.
Returns the currently registered module_name and action_name for the session.
Registers action_name into V$SESSION and V$SQLAREA as the current action for the session.
Registers client_info into V$SESSION as the current client information for the session.
Registers module_name and action_name into V$SESSION and V$SQLAREA as the current module and action for the session.
Inserts or updates runtime data for long-running operations in the V$SESSION_LONGOPS virtual table. Rows are identified by the value of hint ; a new row is acquired when hint is set to the package constant set_session_longops_nohint. Unique combinations of context and stepid also force a new row. The SET_SESSION_LONGOPS procedure is used to track the progress of long-running operations by allowing the entry and modification of data in the V$SESSION_LONGOPS virtual table. 1.3.3 DBMS_AQThe DBMS_AQ package allows you to enqueue to and dequeue messages from queues created in the Oracle Advanced Queuing facility. Oracle8 only.
Adds the message payload to the queue queue_name , using the options specified by the enqueue_options record. The payload_type is either RAW or the name of an object TYPE. Returns the pointer to the message in msgid .
Retrieves the message payload (either a RAW or an object of the specified TYPE) with message_properties specified by the dequeue_options . Also returns the msgid of that message. 1.3.4 DBMS_AQADMThe DBMS_AQADM package provides a set of programs you can use to create, manage, and drop queues and queue tables in the Oracle Advanced Queuing facility.
Creates a queue table named queue_table of queue_payload_type (RAW or the name of an object TYPE).
Creates a queue named queue_name in the queue table queue_table .
Drops the queue_name queue.
Drops the queue_name queue from the queue table queue_table .
Starts the queue_name queue with enqueue and/or dequeue capabilities.
Stops the queue_name queue for enqueue and/or dequeue capabilities with/without waiting for completion of outstanding transactions.
Alters the specified characteristics of the queue_name queue.
Adds the subscriber agent to the queue_name queue.
Removes the subscriber agent from the queue_name queue.
Grants to user_name the ability to create queues that work with multiple consumers.
Returns the list of subscribers for the queue_name queue. PROCEDURE DBMS_AQADM.START_TIME_MANAGER; Starts the Queue Monitor process. PROCEDURE DBMS_AQADM.STOP_TIME_MANAGER; Stops the Queue Monitor process. 1.3.5 DBMS_DDLDBMS_DDL contains programs to recompile stored code, analyze and compute statistics for database objects, and modify the referenceability of object identifiers in Oracle8.
Recompiles the stored PL/SQL object name (case-sensitive) owned by schema of type type . NULL schema uses current schema. Valid values for type are PROCEDURE, FUNCTION, PACKAGE, PACKAGE BODY, and PACKAGE SPECIFICATION.
Reverts references to object table_name by schema affected_schema from table_name owned by table_schema to the default. Oracle8 only.
Makes the object table owned by table_schema the table referenced from schema affected_schema for object name table_name. Oracle8 only.
Analyzes database object name owned by schema of type type (TABLE, INDEX, or CLUSTER) using option method (ESTIMATE, NULL, or DELETE). When method is ESTIMATE, either estimate_rows or estimate_percent must be specified to identify sample size. Additional analyze options specifiable by method_opt are FOR TABLE, FOR ALL COLUMNS [SIZE N ], FOR ALL INDEXED COLUMNS [SIZE N ], and FOR ALL INDEXES. 1.3.6 DBMS_DESCRIBEThe DBMS_DESCRIBE package contains a single procedure used to describe the arguments of a stored PL/SQL procedure or function.
Returns information about the parameters and RETURN type (if a function) of the specified object (procedure or function) in a set of PL/SQL tables, whose types are described in the same package. 1.3.7 DBMS_JOBDBMS_JOB is an interface into the Oracle job queue subsystem that allows automated, unattended scheduling and execution of PL/SQL programs.
Sets or unsets the Boolean broken flag for the job , and optionally sets the next execution date specified by next_date . Jobs flagged with broken = TRUE are not automatically executed.
Changes one or more of the parameters what , next_date , or interval for job .
Changes the date expression used to determine the next execution date for job to interval .
Submits a job with the specified job number and PL/SQL definition what , scheduled to execute at next_date and every interval thereafter. When no_parse is TRUE, parsing of the PL/SQL in what is deferred until execution.
Changes the next scheduled date of execution for job to next_date .
Removes job from the job queue. If job is currently executing, it will run to normal completion, but will not be rescheduled.
Immediately executes job in the current session.
Submits a job to the job queue with PL/SQL definition what , scheduled to execute at next_date and every interval thereafter. Job returns the identification number for the job. When no_parse is TRUE, parsing of the PL/SQL in what is deferred until execution.
Returns a character string in mycall containing a call to DBMS_JOB.ISUBMIT that can be used to re-submit job to the job queue.
Changes the PL/SQL definition for job to what . 1.3.8 DBMS_LOBDBMS_LOB provides a mechanism for accessing and manipulating large objects. LOBs include BLOBs (binary large objects), CLOBs (character large objects), NCLOBs (National Language Support character large objects), and BFILEs (binary files). The CHARACTER SET ANY_CS clauses in the CLOB declarations allow either CLOB or NCLOB locators. Oracle 8 only.
Appends the contents of the source LOB src_lob to the destination LOB dest_lob . Both src_lob and dest_lob must be of the same LOB type: BLOB, CLOB, or NCLOB.
Compares input LOBs lob_1 and lob_2 or file_1 and file_2 across amount bytes, optionally starting the comparison offset_1 and offset_2 bytes into the input files. Both inputs must be of the same LOB type: BLOB, CLOB, NCLOB, or BFILE. Returns 0 if they exactly match, non-0 if they don't match, or NULL if any of amount , offset_1 , or offset_2 are either less than 1 or greater than lobmaxsize.
Copies amount bytes (BLOB) or characters (CLOB) from source LOB lob_loc , starting src_offset bytes or characters into the source LOB to the destination (target) LOB, dest_lob , starting dest_offset into the destination LOB. Both src_lob and dest_lob must be the same LOB type: BLOB, CLOB, or NCLOB.
Erases (zero byte fill) amount bytes (BLOB) or characters (CLOB) in the LOB lob_loc , beginning offset bytes or characters into the LOB lob_loc .
Closes the BFILE file_loc , whether it is open or not. PROCEDURE DBMS_LOB.FILECLOSEALL; Closes all open BFILEs in the current session.
Returns 1 if BFILE file_loc exists; returns 0 otherwise.
Gets directory alias (as previously defined via the CREATE DIRECTORY command) and filename for the given file locator file_loc .
Returns 1 if the BFILE file_loc is open; returns 0 otherwise.
Opens BFILE file_loc for read-only access.
Returns the size in bytes or characters of the LOB lob_loc.
Similar to the built-in function INSTR. Returns the byte (BLOB) or character (CLOB) offset in LOB lob_loc where the nth occurrence of pattern is found. The search begins offset bytes or characters into lob_loc .
Copies amount bytes of data from the source BFILE src_lob to the destination (target) LOB dest_lob , starting src_offset bytes into the source BFILE and dest_offset bytes into the destination (target) LOB.
Copies amount bytes (BLOB) or characters (CLOB) from source LOB lob_loc , starting offset bytes or characters into the LOB to the destination (target) variable, buffer . Returns the actual number of bytes or characters copied in amount .
Similar to the built-in function SUBSTR. Returns amount bytes (BLOB) or characters (CLOB) of the LOB lob_loc starting offset bytes or characters into the LOB.
Truncates the LOB lob_loc to newlen bytes (BLOB) or characters (CLOB).
Copies amount bytes from source variable buffer to the destination LOB lob_loc , starting offset bytes (BLOB) or characters (CLOB) into the LOB, overwriting any existing data in lob_loc . 1.3.9 DBMS_LOCKDBMS_LOCK makes Oracle lock management services available for implementation of specialized, non-data locking and serialization requirements within applications.
Allocates a unique lockhandle for the lock identified by lockname to last for expiration_secs seconds. Also performs a COMMIT.
Converts the lock identified by either id or lockhandle to the mode specified by lockmode , waiting for up to timeout seconds for successful completion. lockmode must be a valid constant as defined in the DBMS_LOCK package. Return values are 0 = success; 1 = timed out; 2 = deadlock; 3 = parameter error; 4 = do not own lock, cannot convert; or 5 = illegal lockhandle.
Releases the lock identified by either id or lockhandle . Return values are: 0 = success; 3 = parameter error; 4 = do not own lock, cannot release; or 5 = illegal lockhandle.
Acquires the lock identified by either id or lockhandle in the mode specified by lockmode , waiting for up to timeout seconds for successful completion. When release_on_commit is TRUE, the lock is automatically released by transaction COMMIT or ROLLBACK. lockmode must be a valid constant as defined in the DBMS_LOCK package. Return values are 0 = success; 1 = timed out; 2 = deadlock; 3 = parameter error; 4 = do not own lock, cannot convert; or 5 = illegal lockhandle.
Suspends the session for seconds seconds. 1.3.10 DBMS_OUTPUTThis package provides a mechanism for displaying information on your session's output device from within a PL/SQL program. You can use it as a crude debugger or trace facility. PROCEDURE DBMS_OUTPUT.DISABLE; Disables output from the package and purges the DBMS_OUTPUT buffer.
Enables output from the package and sets to buffer_size the maximum number of bytes that can be stored in the buffer.
Gets the next line from the buffer and places it in line . A status of 0 means successful retrieval; 1 means failure.
Gets numlines number of lines from the buffer and places them in the lines PL/SQL table. PROCEDURE DBMS_OUTPUT.NEW_LINE; Writes a newline character to the DBMS_OUTPUT buffer.
Puts the data contained in a in the DBMS_OUTPUT buffer and does not append a newline character.
Puts the data contained in a in the DBMS_OUTPUT buffer and then appends a newline character. 1.3.11 DBMS_PIPEDBMS_PIPE permits communication of messages between database sessions using memory-based structures. Communication is asynchronous, non-transactional, and persists beyond session lifetime.
Creates a pipe identified by pipename with maximum size maxpipesize and returns 0. When private is FALSE, the pipe is publicly accessible. FUNCTION DBMS_PIPE.NEXT_ITEM_TYPE RETURN INTEGER; Returns an integer identifying the datatype of the next item in the session message buffer.
Packs item into the session message buffer, overloaded on the datatype of item .
Packs the raw data in item into the session message buffer.
Packs the ROWID data in item into the session message buffer.
Purges all messages from pipename .
Receives a message from pipename into the session message buffer, waiting for up to timeout seconds for successful completion. Returns 0 for success and 1 for timeout.
Removes pipename and frees its memory back to the shared pool, returning 0. PROCEDURE DBMS_PIPE.RESET_BUFFER; Resets the session message buffer's pack and unpack indicators, effectively discarding all contents.
Sends the contents of the session message buffer onto pipename , waiting for up to timeout seconds for successful completion and optionally increasing the maximum size of pipename to maxpipesize . Returns 0 for success and 1 for timeout. FUNCTION DBMS_PIPE.UNIQUE_SESSION_NAME RETURN VARCHAR2; Returns a string identifier unique to the session up to 30 bytes in length.
Unpacks the next data item in the message buffer into item , overloaded on the datatype of item .
Unpacks the next data item in the message buffer into item when it is of datatype RAW.
Unpacks the next data item in the message buffer into item when it is of datatype ROWID. 1.3.12 DBMS_RANDOMDBMS_RANDOM provides a random number generating utility. Oracle8 only.
Initializes the random number generator with the value of seed , which should be at least five digits in length. FUNCTION DBMS_RANDOM.RANDOM RETURN BINARY_INTEGER; Returns a random integer value from the random number generator.
Changes the random number generator's seed value to seed , which should be at least five digits in length. PROCEDURE DBMS_RANDOM.TERMINATE; Releases resources used by the random number generator when no longer needed. 1.3.13 DBMS_ROWIDDBMS_ROWID provides routines for working with ROWIDs. ROWIDs changed structure in Oracle8, and for Oracle8 this built-in works with both the old and new ROWID types. An Oracle7 (restricted) ROWID has three parts in base 16 (hex):
An Oracle8 (extended) ROWID has four parts in base 64:
where:
Returns the block number component of row_id.
Creates a rowid_type ROWID composed of object_number , relative_fno, block_number , and row_number ROWID. rowid_type can beROWID_TYPE_EXTENDED or ROWID_TYPE_RESTRICTED. object_number can be ROWID_OBJECT_UNDEFINED or the object number (OID).
Parses rowid_in into its individual components. rowid_type can beROWID_TYPE_EXTENDED or ROWID_TYPE_RESTRICTED. object_number can be ROWID_OBJECT_UNDEFINED or the object number (OID).
Returns the object number component of row_id.
Returns the relative file number component of row_id.
Returns the row number component of row_id.
Returns the absolute file number for row_id , schema_name , and object_name.
Returns the extended ROWID for the restricted old_rowid , schema_name , and object_name using conversion_type. The conversion_type can be either ROWID_CONVERT_INTERNAL (ROWID was stored in a column of type ROWID) or ROWID_CONVERT_EXTERNAL (ROWID was stored in a column of type CHAR/VARCHAR/VARCHAR2).
Returns a restricted ROWID for the extended old_rowid using conversion_type . The conversion_type can be either ROWID_CONVERT_INTERNAL (ROWID will be stored in a column of type ROWID) or ROWID_CONVERT_EXTERNAL (ROWID will be stored in a column of type CHAR/VARCHAR/VARCHAR2).
Returns ROWID_TYPE_EXTENDED or ROWID_TYPE_RESTRICTED for row_id.
Returns ROWID_VALID or ROWID_INVALID for rowid_in , schema_name , and object_name , using conversion_type . The conversion_type can be either ROWID_CONVERT_INTERNAL ( rowid_in is stored in a column of type ROWID) or ROWID_CONVERT_EXTERNAL ( rowid_in is stored in a column of type CHAR/VARCHAR/VARCHAR2). 1.3.14 DBMS_SESSIONDBMS_SESSION provides facilities to set and modify session settings, enable or disable roles, and manage session resources.
Closes the database link dblink or raises an exception if dblink is not open or is in use. PROCEDURE DBMS_SESSION.FREE_UNUSED_USER_MEMORY; Releases freeable session memory back to the operating system (dedicated connection) or the Oracle shared pool (shared server connection).
Returns TRUE if the rolename is currently enabled in the session.
Returns TRUE if the session identified by uniqueid is still alive. Oracle8 only. PROCEDURE DBMS_SESSION.RESET_PACKAGE; Resets all package states in the session, destroying the values of all persistent package variables.
Overrides the CLOSE_CACHED_OPEN_CURSORS database parameter at the session level with the value in close_cursors .
Sets the session's Trusted Oracle session label to lbl .
Sets the session's default Trusted Oracle label format to fmt .
Sets the National Language Support parameter param to value . When value is a format mask, use a triple-quoted string.
Enables role(s) by appending role_cmd to the SET_ROLE command and executing. Disables all roles by setting role_cmd to NONE.
Turns SQL tracing on or off in the session according to sql_trace (TRUE = on, FALSE = off). FUNCTION DBMS_SESSION.UNIQUE_SESSION_ID RETURN VARCHAR2; Returns a string identifier unique to the session up to 24 bytes in length. 1.3.15 DBMS_SHARED_POOLDBMS_SHARED_POOL contains programs to help manage the Oracle Shared Global Area (SGA) shared pool.
Sets the maximum object size for which the shared pool will flush other objects to make room. Attempts to load objects larger than threshold_size bytes produce ORA-04031 errors if sufficient space is not available.
Pins the object identified by name in the shared pool. The object's type is identified by flag : "P" or "p" for package, procedure, or function; "Q" or "q" for sequences; and "R" or "r" for triggers. Specifies any other character flag to pin a cursor identified by address and hash value (from V$SQLAREA) in name.
Displays objects and cursors in the shared pool that exceed minsize kilobytes in size.
Unpins the object of type flag and identified by name from the shared pool. Valid flag values are the same values as for DBMS_SHARED_POOL.KEEP. 1.3.16 DBMS_SPACEDBMS_SPACE contains procedures that provide internal space utilization and freelist information about table, index, and cluster segments.
Returns into free_blks the number of blocks on the freelist for segment segment_name of type segment_type (TABLE, INDEX, or CLUSTER) owned by segment_owner in partition partition_name (optional, and Oracle8 only). Scan_limit (optional) limits the number of free blocks scanned.
Returns the highwater mark ( last_used_extent_file_id , last_used_extent_block_id , and last_used_block ), space used ( total_blocks , total_bytes ), and space unused ( unused_blocks , unused_bytes ) in segment segment_name of type segment_type (TABLE, INDEX, or CLUSTER) owned by segment_owner in partition partition_name. Optional, and Oracle8 only. 1.3.17 DBMS_SQLDBMS_SQL provides routines for using dynamic SQL within PL/SQL. For Oracle8, this is the routine that provides support for array operations in PL/SQL.
Binds the table_variable array to the placeholder name in the parsed (but not executed) SQL statement in the cursor c (returned by the OPEN_CURSOR call). For Oracle8, used to perform array processing. The < table_variable IN datatype > can be any of the following: n_tab IN DBMS_SQL.NUMBER_TABLE c_tab IN DBMS_SQL.VARCHAR2_TABLE d_tab IN DBMS_SQL.DATE_TABLE bl_tab IN DBMS_SQL.BLOB_TABLE cl_tab IN DBMS_SQL.CLOB_TABLE bf_tab IN DBMS_SQL.BFILE_TABLE The optional argument index1 defines the lower bound (first row) within the table and index2 defines the upper bound (last row). Oracle 8 only.
Binds the scalar value to the placeholder name in the parsed SQL statement in the cursor c , optionally with maximum expected size of value being out_value_size .
Binds the scalar CHAR/NCHAR value to the placeholder name in the parsed SQL statement in the cursor c , optionally with maximum expected size of value being out_value_size .
Binds the scalar RAW value to the placeholder name in the parsed SQL statement in the cursor c (returned by the OPEN_CURSOR call), optionally with maximum expected size of value being out_value_size .
Binds the scalar ROWID value to the placeholder name in the parsed SQL statement in the cursor c .
Closes cursor c .
Transfers the contents of column number position in the SELECT list of the fetched cursor c into the variable value , optionally setting actual_length to the pre-truncated length in bytes, and column_error to the error code for the specified value. Truncation may occur due to a difference in size between the retrieved value in the cursor and the variable length. MLSLABEL is for Trusted Oracle only.
Transfers the array contents of column number position in the SELECT list of the fetched array from cursor c into the PL/SQL table. For Oracle8 only, the table_parameter and table_type can be any of the following: n_tab IN DBMS_SQL.NUMBER_TABLE c_tab IN DBMS_SQL.VARCHAR2_TABLE d_tab IN DBMS_SQL.DATE_TABLE bl_tab IN DBMS_SQL.BLOB_TABLE cl_tab IN DBMS_SQL.CLOB_TABLE bf_tab IN DBMS_SQL.BFILE_TABLE
Transfers the contents of column number position in the SELECT list of the fetched cursor c into the CHAR/NCHAR variable value , optionally setting actual_length to the pre-truncated length in characters, and the column_error to the error code for the specified value. Truncation may occur due to a difference in size between the retrieved value in the cursor and the variable length.
Transfers the contents of column number position in the SELECT list of the fetched cursor c into the VARCHAR2 variable value , starting offset bytes into the LONG column and extending for length bytes. Also sets value_length to the actual length of the retrieved value.
Transfers the contents of column number position in the SELECT list of the fetched cursor c into the RAW variable value , optionally setting actual_length to the pre-truncated length in bytes, and the column_error to the error code for the specified value. Truncation may occur due to a difference in size between the retrieved value in the cursor and the variable length.
Transfers the contents of column number position in the SELECT list of the fetched cursor c into the ROWID variable value , optionally setting actual_length to the pre-truncated length in bytes, and the column_error to the error code for the specified value. Truncation may occur due to a difference in size between the retrieved value in the cursor and the variable length.
Defines the datatype and size of the elements in the fetch array for column number position in the SELECT list of the cursor c as the same datatype and size as the nested table table_parameter , beginning with row lower_bound , and having a maximum array size of cnt rows. For Oracle8, table_parameter and table_type can be any of these: n_tab IN DBMS_SQL.NUMBER_TABLE c_tab IN DBMS_SQL.VARCHAR2_TABLE d_tab IN DBMS_SQL.DATE_TABLE bl_tab IN DBMS_SQL.BLOB_TABLE cl_tab IN DBMS_SQL.CLOB_TABLE bf_tab IN DBMS_SQL.BFILE_TABLE
The variable or expression column defines the datatype for column number position in the SELECT list of the cursor c . MLSLABEL is for Trusted Oracle only.
The variable or expression column defines the datatype as VARCHAR2/NVARCHAR2 and size as column_size characters for column number position in the SELECT list of the cursor c .
The variable or expression column defines the datatype as CHAR/NCHAR and size as column_size characters for column number position in the SELECT list of the cursor c .
Defines the datatype as LONG for column number position in the SELECT list of the cursor c .
The variable or expression column as RAW of size column_size bytes for column number position in the SELECT list of the cursor c .
The variable or expression column defines the datatype as ROWID for column number position in the SELECT list of the cursor c .
Populates PL/SQL table desc_t of type DBMS_SQL.DESC_REC with the description of columns of cursor c . col_cnt is the number of columns in c and the number of rows in desc_t.
For INSERT, UPDATE, or DELETE statements, returns the number of rows processed by executing the cursor c . For all other SQL statements, executes the cursor c and returns an undefined value.
Returns the number of rows fetched by executing and fetching cursor c . Raises an exception if more than one row is fetched when exact is set to TRUE. Multiple rows require Oracle8 and array processing.
Fetches and returns the number of rows fetched from cursor c , or 0 (zero) when there are no more rows to fetch.
Returns TRUE if cursor c is open, FALSE otherwise. FUNCTION DBMS_SQL.LAST_ERROR_POSITION RETURN INTEGER; Returns the byte offset in the SQL statement where the last error occurred. Must be called immediately after an EXECUTE or EXECUTE_AND_FETCH (typically in the exception handler). FUNCTION DBMS_SQL.LAST_ROW_COUNT RETURN INTEGER; Returns the total number of rows fetched so far -- similar to the %ROWCOUNT attribute of static cursors. FUNCTION DBMS_SQL.LAST_ROW_ID RETURN ROWID; Returns the ROWID of the most recently fetched row. Must be called immediately after a FETCH_ROWS or EXECUTE_AND_FETCH. FUNCTION DBMS_SQL.LAST_SQL_FUNCTION_CODE RETURN INTEGER; Returns the SQL function code for the SQL statement. A complete list of these function codes can be found in the Oracle Corporation's Server Reference Manual in the section describing the table column V$SESSION.COMMAND. FUNCTION DBMS_SQL.OPEN_CURSOR RETURN INTEGER; Returns an INTEGER pointer to memory allocated for a dynamic cursor.
Parses a SQL statement less than 32K bytes in length and associates it with cursor c , following database behavior specified by language_flag (either DBMS_SQL.NATIVE, DBMS_SQL.V7, or DBMS_SQL.V6). Do not terminate your SQL string with a semicolon unless it is a PL/SQL block. For DDL statements (e.g., TRUNCATE TABLE), this also executes the statement.
Parses a SQL statement contained in rows lb through ub in the PL/SQL table and associates it with cursor c , following database behavior specified by language_flag (either DBMS_SQL.NATIVE, DBMS_SQL.V7, or DBMS_SQL.V6), and appending a line feed after each row from statement if lfflg is set to TRUE.
Retrieves the value of the host variable name in cursor c into the PL/SQL NUMBER variable value . MLSLABEL is for Trusted Oracle only.
Retrieves the values of the host variable name in cursor c into the PL/SQL table value . For Oracle8 only, the table_type can be one of the following: DBMS_SQL.NUMBER_TABLE DBMS_SQL.VARCHAR2_TABLE DBMS_SQL.DATE_TABLE DBMS_SQL.BLOB_TABLE DBMS_SQL.CLOB_TABLE DBMS_SQL.BFILE_TABLE
Retrieves the value of the host variable name in cursor c into the CHAR/NCHAR table value.
Retrieves the value of the host variable name in cursor c into the RAW variable value.
Retrieves the value of the host variable name in cursor c into the ROWID variable value . 1.3.18 DBMS_STANDARDDBMS_STANDARD contains "kernel extensions to package STANDARD." These include functions and procedures for use in triggers to support transactions. These functions and procedures, like those in package STANDARD, are special in that they do not need to be qualified with the owner or package name, and are usually assumed to be part of the PL/SQL language.
Raises PL/SQL exception num , together with text msg from a stored program. The error can be placed together with any other errors on the error stack. If keeperrorstack is set to TRUE, default behavior is to replace the error stack with this single exception. num can range from -20999 to -20000, and msg can be up to 2048 bytes long. FUNCTION INSERTING RETURN boolean; FUNCTION DELETING RETURN boolean; FUNCTION UPDATING RETURN boolean; FUNCTION UPDATING (colnam VARCHAR2) RETURN boolean; Conditional predicates used to determine the type of Data Manipulation Language (DML) operation that caused a trigger to fire. These functions are only useful within triggers; for example "...IF INSERTING THEN...." PROCEDURE COMMIT; PROCEDURE COMMIT_CM (vc VARCHAR2); PROCEDURE ROLLBACK_NR; PROCEDURE ROLLBACK_SV(save_point VARCHAR2); PROCEDURE SAVEPOINT(save_point VARCHAR2); PROCEDURE SET_TRANSACTION_USE(vc VARCHAR2); These procedures support transaction control. They are analogous to the SQL statements: COMMIT, COMMIT COMMENT, ROLLBACK, ROLLBACK TO SAVEPOINT, SAVEPOINT, and SET TRANSACTION USE ROLLBACK SEGMENT. 1.3.19 DBMS_SYSTEMDBMS_SYSTEM contains procedures for setting special internal trace events, including SQL tracing, at the session level.
Returns the current session's event level setting for trace event number iev into variable oev .
Sets the level for event number ev in the session identified by sid si and serial number se to the value specified by le . Variable nm is used to specify the event name.
Turns SQL tracing on or off in the session identified by sid ( sid) and serial number ( serial#) according to the value of sql_trace (TRUE = on; FALSE = off). 1.3.20 DBMS_TRANSACTIONDBMS_TRANSACTION contains a number of programs for local and distributed transaction management. PROCEDURE DBMS_TRANSACTION.ADVISE_COMMIT; Advises remote databases that in-doubt distributed transactions should be committed if possible. PROCEDURE DBMS_TRANSACTION.ADVISE_NOTHING; Removes advice from remote databases regarding in-doubt distributed transactions. PROCEDURE DBMS_TRANSACTION.ADVISE_ROLLBACK; Advises remote databases that in-doubt distributed transactions should be rolled back. PROCEDURE DBMS_TRANSACTION.BEGIN_DISCRETE_TRANSACTION; Sets the current transaction to use discrete transaction processing. PROCEDURE DBMS_TRANSACTION.COMMIT; Commits the current transaction.
Commits the current transaction and sends cmnt as the in-doubt transaction comment to remote databases during distributed transactions.
Forces the local portion of the in-doubt distributed transaction identified by transaction id xid and (optionally) system change number scn to commit.
Returns Oracle's unique identifier for the current transaction, optionally beginning a new transaction when create_transaction is TRUE.
Forces Oracle to purge all local entries for the distributed transaction identified by xid when a participating node has been permanently lost.
Forces Oracle to purge local entries for the mixed outcome distributed transaction identified locally by xid . PROCEDURE DBMS_TRANSACTION.READ_ONLY; Establishes transaction-level read consistency, where all queries return read-consistent images of data as of the transaction's start time. PROCEDURE DBMS_TRANSACTION.READ_WRITE; Establishes statement-level read consistency, which is also the default behavior. PROCEDURE DBMS_TRANSACTION.ROLLBACK; Rolls back the current transaction.
Rolls back the local portion of the in-doubt distributed transaction identified by xid .
Rolls back the current transaction to the savepoint savept .
Sets a savepoint named savept in the current transaction. FUNCTION DBMS_TRANSACTION.STEP_ID RETURN NUMBER; Returns a unique positive integer that orders the DML operations of the current transaction.
Assigns the current transaction to rollback segment rb_name . 1.3.21 DBMS_UTILITYDBMS_UTILITY provides procedures and functions to perform a number of useful tasks, including parsing and tokenizing name references, obtaining database configuration information, analyzing objects, obtaining error and call stack information, and timing code execution.
Analyzes all tables, clusters, and indexes in the database using option method (ESTIMATE, COMPUTE, or DELETE). When method is ESTIMATE, either estimate_rows or estimate_percent must be specified to identify sample size. Additional analyze options specifiable by method_opt are: FOR TABLE; FOR ALL COLUMNS [SIZE N ]; FOR ALL INDEXED COLUMNS [SIZE N ]; or FOR ALL INDEXES.
Analyzes the partitioned table or index object_name owned by schema of type object_type (T = TABLE, I = INDEX) in parallel using Oracle job queue processes. command_type indicates the type of analysis to perform and command_opt specifies additional options. sample_clause specifies sample size when command_type is E (estimate) using `SAMPLE N ROWS' or `SAMPLE N PERCENT'. Oracle8 only. Valid command_type values are: C for compute statistics, E for estimate statistics, D for delete statistics, or V for validate structure. Valid command_opt values for command_type C or T are: FOR TABLE, FOR ALL LOCAL INDEXES, FOR ALL COLUMNS, or any combination of FOR options of the ANALYZE command. Valid command_opt values for command_type V are: CASCADE when object_type is T (table).
Analyzes all tables, clusters, and indexes in schema using method (ESTIMATE, COMPUTE, or DELETE). When method is ESTIMATE, either estimate_rows or estimate_percent must be specified to identify sample size. Additional analyze options specifiable by method_opt are: FOR TABLE, FOR ALL COLUMNS [SIZE N ], FOR ALL INDEXED COLUMNS [SIZE N ], or FOR ALL INDEXES.
Parses the comma-delimited list and returns the tokens in the PL/SQL table tab of type DBMS_UTILITY.UNCL_ARRAY. The number of rows in tab is returned in tablen .
Compiles all stored PL/SQL programs (procedures, functions, and packages) owned by schema .
Returns the block offset number of the data block address specified in dba . FUNCTION DBMS_UTILITY.DATA_BLOCK_ADDRESS_FILE (dba IN NUMBER) RETURN NUMBER; Returns the file number component of the data block address specified in dba .
Returns the Oracle version of the database in version and the setting of the INIT.ORA COMPATIBLE parameter in compatibility (or NULL). Oracle8 only.
Executes the DDL statement specified by parse_string. Oracle8 only. FUNCTION DBMS_UTILITY.FORMAT_CALL_STACK RETURN VARCHAR2; Returns the current PL/SQL call stack as a formatted string. FUNCTION DBMS_UTILITY.FORMAT_ERROR_STACK RETURN VARCHAR2; Returns the current PL/SQL error stack as a formatted string.
Returns a hash function value for name with a minimum possible value of base using a hash table of size hash_size .
Returns information about the current setting of the database initialization ( INIT.ORA ) parameter parnam. Oracle8 only. intval returns the following values:
strval returns NULL, or the value of a string parameter: 0 if the parameter is Boolean or numeric; 1 if the parameter is a string. FUNCTION DBMS_UTILITY.GET_TIME RETURN NUMBER; Returns a number indicating the number of 1/100ths of a seconds elapsed since an (unknown) arbitrary time in the past. FUNCTION DBMS_UTILITY.IS_PARALLEL_SERVER RETURN BOOLEAN; Returns TRUE if the instance is running in parallel server mode, and FALSE otherwise.
Returns a valid data block address for file at block offset block .
Resolves the reference name and returns specific identification information about the object referenced as follows: schema is the object's owner; part1 is the object name or package name for a package; part2 is the program name when object is a package; dblink is the database link if name resolves to a remote object; part1_type identifies the type of object; object_number is the local object number or NULL if name could not be fully resolved locally. part1_type is 5 if the object is a synonym; 7 if the object is a procedure; 8 if the object is a function; 9 if the object is a package. Note that context must be set to 1.
Uses the PL/SQL parser to tokenize the reference name into its constituent components according to the following format: a [ . b [ . c ] ] [ @ dblink ] nextpos is the starting position of the next token. FUNCTION DBMS_UTILITY.PORT_STRING RETURN VARCHAR2; Returns a string with operating system-specific identifying information about the version of Oracle that is running.
Converts the PL/SQL table tab of type DBMS_UTILITY.UNCL_ARRAY into a comma-delimited string returned in list , with the number of rows converted returned in tablen . 1.3.22 UTL_FILEUTL_FILE allows PL/SQL programs to read from and write to operating system files on the server where the Oracle database resides.
Closes the file identified by file handle file and sets the value of file id to NULL. PROCEDURE UTL_FILE.FCLOSE_ALL; Closes all opened files; however, the id fields of any file handles will not be set to NULL.
Forces any buffered data for file handle file to be written out immediately.
Returns a file handle of type UTL_FILE.FILE_TYPE upon successfully opening file filename in directory location in mode open_mode , or raises an exception. Valid open_mode values are:
Valid location values are directories specified by the Oracle initialization parameter UTL_FILE_DIR.
Reads the next line in file handle file into buffer . Raises NO_DATA_FOUND exception when reading past end of file and VALUE_ERROR exception when buffer is too small for the data.
Returns TRUE if the file handle file is currently open in any mode and FALSE otherwise.
Places lines newline characters into file handle file .
Places the data in buffer into file handle file without a newline terminator.
Places the data in buffer into file handle file with a newline character appended.
Writes a formatted message out to file handle file using format as the template, replacing up to five %s format elements with the values of arg1-arg5 . format can contain the following items: any literal text; %s indicating argN substitution (up to five allowed); or \n indicating newline (any number allowed). 1.3.23 UTL_RAWUTL_RAW provides routines for accessing and manipulating RAW datatypes. These routines perform conversions, divisions, combinations, and bitwise operations on RAW datatypes.
Returns the bitwise logical AND of r1 and r2 .
Returns the bitwise logical complement of r1 and r2 .
Returns the bitwise logical OR of r1 and r2 .
Returns the bitwise logical XOR of r1 and r2 .
Returns VARCHAR2 c to RAW, converting datatype only.
Returns RAW c to VARCHAR2, converting datatype only.
Returns 0 if r1 and r2 are identical. Returns first byte position of difference in r1 and r2 . If r1 and r2 are different lengths, right pad the shorter with pad .
Returns the concatenation of r1 through r12 . The result must be less than 32K. r3 through r12 are optional.
Returns r in to_charset after conversion from from_charset. from_charset and to_charset are NLS character sets.
Concatenates r , n number of times, and returns the result.
Returns the number of bytes in r .
Returns the target overlaid with the overlay_str string beginning pos bytes into target and continuing for len bytes, right padding with pad as necessary. If pos is greater than the length of target, fills the missing section with pad .
Returns the bytes in r in reverse order.
Returns a portion of r beginning at pos and extending for len bytes.
Returns the contents of r, translating bytes found in from_set to to_set . If from_set is longer than to_set , the unmatched bytes are removed from r .
Returns the contents of r, translating bytes found in from_set to to_set . If from_set is longer than to_set , the unmatched bytes are translated to pad .
Returns a raw string containing all bytes in order between start_byte and end_byte , inclusive. If start_byte is greater than end_byte , the result wraps from 0xFF to 0x00. 1.3.24 UTL_REFUTL_REF contains routines for selecting and modifying instances of an object type in an object table. The name of the table does not have to be known. Oracle8.0.4 only.
Deletes the object (actually the row containing the object) identified by reference .
Locks the object referenced by reference.
Locks the object referenced by reference and retrieves the object into object . Similar to a SELECT FOR UPDATE statement.
Retrieves the object referenced by reference into object .
Replaces an object in the database identified by reference with the object object .
Copyright (c) 2000 O'Reilly & Associates. All rights reserved. | |||||||||
|
|