Oracle Dbms Download

 
Oracle Dbms Download Rating: 5,0/5 7237 votes
  1. Download Oracle 11g Database
  2. Database Management System

Oracle dbms free download - SQL Plus Master - Oracle DBMS Tutorial, DBMS Tutorials, DBA Easy Control for Oracle, and many more programs. Oracle’s automated tools make it seamless to move your on-premises database to Oracle Cloud with virtually no downtime. Oracle Database Cloud Service uses the same standards, products, and skills you currently use on premises, making it easy to move database workloads to the public cloud.

2 Installing Oracle Database and Creating a Database. This chapter describes how to install Oracle Database software and create a database. If you are using an earlier release of Oracle Database and want to install a later release of the Oracle Database software, then you can upgrade your existing Oracle Database and use it with the new release of the database software. The DBMSOUTPUT package is commonly used to debug stored procedures and triggers. This package can also be used to enable you to retrieve information about an object and format this output, as shown in 'Example 3: Retrieving Information About an Object'. Edit My Profile Log Out Contact Us 1-800-223-1711(US) Chat with an Oracle Expert Sales Chat Tech Cloud Chat Support Chat. I remember when I installed Oracle for the first time, I spent a couple of weeks or more, reading through 300 pages of installation documentation, started over again several times until it worked, and also discovered some installer bucks that were confirmed with Oracle support.

The DBMS_SQL package provides an interface to use dynamic SQL to parse any data manipulation language (DML) or data definition language (DDL) statement using PL/SQL. For example, you can enter a DROPTABLE statement from within a stored procedure by using the PARSE procedure supplied with the DBMS_SQL package.

See Also:

  • For more information on native dynamic SQL, see Oracle Database PL/SQL User's Guide and Reference.
  • For a comparison of DBMS_SQL and native dynamic SQL, see Oracle Database Application Developer's Guide - Fundamentals.

This chapter contains the following topics:

    • Overview

    • Security Model

    • Constants

    • Types

    • Exceptions

    • Operational Notes

    • Examples

Using DBMS_SQL

Overview

Oracle lets you to write stored procedures and anonymous PL/SQL blocks that use dynamic SQL. Dynamic SQL statements are not embedded in your source program; rather, they are stored in character strings that are input to, or built by, the program at runtime. This enables you to create more general-purpose procedures. For example, dynamic SQL lets you create a procedure that operates on a table whose name is not known until runtime.

Native Dynamic SQL is an alternative to DBMS_SQL that lets you place dynamic SQL statements directly into PL/SQL blocks. In most situations, Native Dynamic SQL is easier to use and performs better than DBMS_SQL. However, Native Dynamic SQL itself has certain limitations:

  • There is no support for so-called Method 4 (for dynamic SQL statements with an unknown number of inputs or outputs)

  • There is no support for SQL statements larger than 32K bytes

Also, there are some tasks that can only be performed using DBMS_SQL.

The ability to use dynamic SQL from within stored procedures generally follows the model of the Oracle Call Interface (OCI).

PL/SQL differs somewhat from other common programming languages, such as C. For example, addresses (also called pointers) are not user-visible in PL/SQL. As a result, there are some differences between the Oracle Call Interface and the DBMS_SQL package. These differences include the following:

  • The OCI uses bind by address, while the DBMS_SQL package uses bind by value.

  • With DBMS_SQL you must call VARIABLE_VALUE to retrieve the value of an OUT parameter for an anonymous block, and you must call COLUMN_VALUE after fetching rows to actually retrieve the values of the columns in the rows into your program.

  • The current release of the DBMS_SQL package does not provide CANCEL cursor procedures.

  • Indicator variables are not required, because NULLs are fully supported as values of a PL/SQL variable.

A sample usage of the DBMS_SQL package follows. For users of the Oracle Call Interfaces, this code should seem fairly straightforward.

Security Model

DBMS_SQL is compiled with AUTHIDCURRENT_USER.

Any DBMS_SQL subprograms called from an anonymous PL/SQL block are run using the privileges of the current user.

See Also:

For more information about invoking subprograms using either Invoker or Definer Rights, see Oracle Database PL/SQL User's Guide and Reference

Constants

Types

General Types

Bulk SQL Types

BFILE_TABLE

BINARY_DOUBLE_TABLE

BINARY_FLOAT_TABLE

BLOB_TABLE

CLOB_TABLE

DATE_TABLE

INTERVAL_DAY_TO_SECOND_TABLE

INTERVAL_YEAR_TO_MONTH_TABLE

DESC_REC, DESC_TAB

NUMBER_TABLE

TIME_TABLE

TIME_WITH_TIME_ZONE_TABLE

TIMESTAMP_TABLE

TIMESTAMP_WITH_LTZ_TABLE

UROWID_TABLE

VARCHAR2_TABLE

VARCHAR2A, DESC_REC2

VARCHAR2S

Exceptions

This exception is raised by the COLUMN_VALUE Procedure or the VARIABLE_VALUE Procedures when the type of the given OUT parameter (for where to put the requested value) is different from the type of the value.

Operational Notes

Execution Flow

OPEN_CURSOR

To process a SQL statement, you must have an open cursor. When you call the OPEN_CURSOR Function function, you receive a cursor ID number for the data structure representing a valid cursor maintained by Oracle. These cursors are distinct from cursors defined at the precompiler, OCI, or PL/SQL level, and are used only by the DBMS_SQL package.


PARSE

Every SQL statement must be parsed by calling the PARSE Procedure. Parsing the statement checks the statement's syntax and associates it with the cursor in your program.

You can parse any DML or DDL statement. DDL statements are run on the parse, which performs the implied commit.

Note:

When parsing a DDL statement to drop a package or a procedure, a deadlock can occur if you're still using a procedure in the package. After a call to a procedure, that procedure is considered to be in use until execution has returned to the user side. Any such deadlock timeouts after five minutes.

The execution flow of DBMS_SQL is shown in Figure 100-1.

Figure 100-1 DBMS_SQL Execution Flow

Download
Description of 'Figure 100-1 DBMS_SQL Execution Flow'

BIND_VARIABLE or BIND_ARRAY

Many DML statements require that data in your program be input to Oracle. When you define a SQL statement that contains input data to be supplied at runtime, you must use placeholders in the SQL statement to mark where data must be supplied.

For each placeholder in the SQL statement, you must call one of the bind procedures, the BIND_ARRAY Procedures or the BIND_VARIABLE Procedures, to supply the value of a variable in your program (or the values of an array) to the placeholder. When the SQL statement is subsequently run, Oracle uses the data that your program has placed in the output and input, or bind, variables.

DBMS_SQL can run a DML statement multiple times — each time with a different bind variable. The BIND_ARRAY procedure lets you bind a collection of scalars, each value of which is used as an input variable once for each EXECUTE. This is similar to the array interface supported by the OCI.


DEFINE_COLUMN, DEFINE_COLUMN_LONG, or DEFINE_ARRAY

The columns of the row being selected in a SELECT statement are identified by their relative positions as they appear in the select list, from left to right. For a query, you must call one of the define procedures (DEFINE_COLUMN, DEFINE_COLUMN_LONG, or DEFINE_ARRAY) to specify the variables that are to receive the SELECT values, much the way an INTO clause does for a static query.

Use the DEFINE_COLUMN_LONG procedure to define LONG columns, in the same way that DEFINE_COLUMN is used to define non-LONG columns. You must call DEFINE_COLUMN_LONG before using the COLUMN_VALUE_LONG procedure to fetch from the LONG column.

Use the DEFINE_ARRAY procedure to define a PL/SQL collection into which you want to fetch rows in a single SELECT statement. DEFINE_ARRAY provides an interface to fetch multiple rows at one fetch. You must call DEFINE_ARRAY before using the COLUMN_VALUE procedure to fetch the rows.


EXECUTE

Call the EXECUTE function to run your SQL statement.


FETCH_ROWS or EXECUTE_AND_FETCH

The FETCH_ROWS function retrieves the rows that satisfy the query. Each successive fetch retrieves another set of rows, until the fetch is unable to retrieve anymore rows. Instead of calling EXECUTE and then FETCH_ROWS, you may find it more efficient to call EXECUTE_AND_FETCH if you are calling EXECUTE for a single execution.


VARIABLE_VALUE, COLUMN_VALUE, or COLUMN_VALUE_LONG

For queries, call COLUMN_VALUE to determine the value of a column retrieved by the FETCH_ROWS call. For anonymous blocks containing calls to PL/SQL procedures or DML statements with returning clause, call VARIABLE_VALUE to retrieve the values assigned to the output variables when statements were run.

To fetch just part of a LONG database column (which can be up to two gigabytes in size), use the COLUMN_VALUE_LONG procedure. You can specify the offset (in bytes) into the column value, and the number of bytes to fetch.


CLOSE_CURSOR

When you no longer need a cursor for a session, close the cursor by calling CLOSE_CURSOR. If you are using an Oracle Open Gateway, then you may need to close cursors at other times as well. Consult your Oracle Open Gateway documentation for additional information.

If you neglect to close a cursor, then the memory used by that cursor remains allocated even though it is no longer needed.


Processing Queries

If you are using dynamic SQL to process a query, then you must perform the following steps:

  1. Specify the variables that are to receive the values returned by the SELECT statement by calling the DEFINE_COLUMN Procedure, the DEFINE_COLUMN_LONG Procedure, or the DEFINE_ARRAY Procedure.

  2. Run your SELECT statement by calling the EXECUTE Function.

  3. Call the FETCH_ROWS Function (or EXECUTE_AND_FETCH) to retrieve the rows that satisfied your query.

  4. Call COLUMN_VALUE Procedure or COLUMN_VALUE_LONG Procedure to determine the value of a column retrieved by the FETCH_ROWS Function for your query. If you used anonymous blocks containing calls to PL/SQL procedures, then you must call the VARIABLE_VALUE Procedures to retrieve the values assigned to the output variables of these procedures.

Processing Updates, Inserts, and Deletes

If you are using dynamic SQL to process an INSERT, UPDATE, or DELETE, then you must perform the following steps:

  1. You must first run your INSERT, UPDATE, or DELETE statement by calling the EXECUTE Function.

  2. If statements have the returning clause, then you must call the VARIABLE_VALUE Procedures to retrieve the values assigned to the output variables.

Locating Errors

There are additional functions in the DBMS_SQL package for obtaining information about the last referenced cursor in the session. The values returned by these functions are only meaningful immediately after a SQL statement is run. In addition, some error-locating functions are only meaningful after certain DBMS_SQL calls. For example, you call the LAST_ERROR_POSITION Function immediately after a PARSE.

Examples

This section provides example procedures that make use of the DBMS_SQL package.

Example 1

This example does not require the use of dynamic SQL because the text of the statement is known at compile time., but it illustrate the basic concept underlying the package.

The DEMO procedure deletes all of the employees from the EMP table whose salaries are greater than the salary that you specify when you run DEMO.

Example 2

The following sample procedure is passed a SQL statement, which it then parses and runs:

DDL statements are run by the parse call, which performs the implied commit.

Creating such a procedure enables you to perform the following operations:

  • The SQL statement can be dynamically generated at runtime by the calling program.

  • The SQL statement can be a DDL statement or a DML without binds.

For example, after creating this procedure, you could make the following call:

You could even call this procedure remotely, as shown in the following example. This lets you perform remote DDL.

Example 3

The following sample procedure is passed the names of a source and a destination table, and copies the rows from the source table to the destination table. This sample procedure assumes that both the source and destination tables have the following columns:

This procedure does not specifically require the use of dynamic SQL; however, it illustrates the concepts of this package.

Examples 3, 4, and 5: Bulk DML

This series of examples shows how to use bulk array binds (table items) in the SQL DML statements DELETE, INSERT, and UPDATE.

In a DELETE statement, for example, you could bind in an array in the WHERE clause and have the statement be run for each element in the array:

In the preceding example, only elements 1 through 4 are used as specified by the BIND_ARRAY call. Each element of the array potentially deletes a large number of employees from the database.

Here is an example of a bulk INSERT statement:

When the execute takes place, all 10 of the employees are inserted into the table.

Finally, here is an example of an bulk UPDATE statement.

When the EXECUTE Function call happens, the addresses of all employees are updated at once. The two collections are always stepped in unison. If the WHERE clause returns more than one row, then all those employees get the address the addr_array happens to be pointing to at that time.

Examples 6 and 7: Defining an Array

The following examples show how to use the DEFINE_ARRAY procedure:

Each time the preceding example does a FETCH_ROWS Function call, it fetches 10 rows that are kept in DBMS_SQL buffers. When the COLUMN_VALUE Procedure call is run, those rows move into the PL/SQL table specified (in this case n_tab), at positions -10 to -1, as specified in the DEFINE statements. When the second batch is fetched in the loop, the rows go to positions 0 to 9; and so on.

A current index into each array is maintained automatically. This index is initialized to 'indx' at EXECUTE and keeps getting updated every time a COLUMN_VALUE call is made. If you reexecute at any point, then the current index for each DEFINE is re-initialized to 'indx'.

In this way the entire result of the query is fetched into the table. When FETCH_ROWS cannot fetch 10 rows, it returns the number of rows actually fetched (if no rows could be fetched, then it returns zero) and exits the loop.

Here is another example of using the DEFINE_ARRAY procedure:

Consider a table MULTI_TAB defined as:

To select everything from this table and move it into four PL/SQL tables, you could use the following simple program:

The four tables can be used for anything. One usage might be to use BIND_ARRAY to move the rows to another table by using a query such as 'INSERT into SOME_T values (:a, :b, :c, :d);

Example 8: Describe Columns

This can be used as a substitute to the SQL*Plus DESCRIBE call by using a SELECT * query on the table that you want to describe.

Example 9: RETURNING clause

The RETURNING clause was added to DML statements in an earlier Oracle database release. With this clause, INSERT, UPDATE, and DELETE statements can return values of expressions. These values are returned in bind variables.

DBMS_SQL.BIND_VARIABLE is used to bind these outbinds if a single row is inserted, updated, or deleted. If multiple rows are inserted, updated, or deleted, then DBMS_SQL.BIND_ARRAY is used. DBMS_SQL.VARIABLE_VALUE must be called to get the values in these bind variables.

Note:

This is similar to DBMS_SQL.VARIABLE_VALUE, which must be called after running a PL/SQL block with an out-bind inside DBMS_SQL.

i) Single row insert

ii) Single row update

iii) Single row delete

iv) Multiple row insert

v) Multiple row Update.

Note:

bnd1 and bnd2 can be array as well. The value of the expression for all the rows updated will be in bnd3. There is no way of differentiating which rows got updated of each value of bnd1 and bnd2.

vi) Multiple row delete

vii) Out-bind in bulk PL/SQL

Note:

DBMS_SQL.BIND_ARRAY of number_Table internally binds a number. The number of times statement is run depends on the number of elements in an inbind array.

Summary of DBMS_SQL Subprograms

Table 100-1 DBMS_SQL Package Subprograms

SubprogramDescription

Binds a given value to a given collection

Binds a given value to a given variable

Closes given cursor and frees memory

Returns value of the cursor element for a given position in a cursor

Returns a selected part of a LONG column, that has been defined using DEFINE_COLUMN_LONG

Defines a collection to be selected from the given cursor, used only with SELECT statements

Defines a column to be selected from the given cursor, used only with SELECT statements

Defines a LONG column to be selected from the given cursor, used only with SELECT statements

Describes the columns for a cursor opened and parsed through DBMS_SQL

Describes describes the specified column, an alternative to DESCRIBE_COLUMNS Procedure

Executes a given cursor

Executes a given cursor and fetch rows

Fetches a row from a given cursor

Returns TRUE if given cursor is open

Returns byte offset in the SQL statement text where the error occurred

Returns cumulative count of the number of rows fetched

Returns ROWID of last row processed

Returns SQL function code for statement

Returns cursor ID number of new cursor

Parses given statement

Returns value of named variable for given cursor


BIND_ARRAY Procedures

This procedure binds a given value or set of values to a given variable in a cursor, based on the name of the variable in the statement.

Syntax

Where the <table_variable> and its corresponding <datatype> can be any one of the following matching pairs:

Notice that the BIND_ARRAY procedure is overloaded to accept different datatypes.

Parameters

Table 100-2 BIND_ARRAY Procedure Parameters

ParameterDescription

c

ID number of the cursor to which you want to bind a value.

name

Name of the collection in the statement.

table_variable

Local variable that has been declared as <datatype>.

index1

Index for the table element that marks the lower bound of the range.

index2

Index for the table element that marks the upper bound of the range.


Usage Notes

The length of the bind variable name should be <=30 bytes.

For binding a range, the table must contain the elements that specify the range — tab(index1) and tab(index2) — but the range does not have to be dense. Index1 must be less than or equal to index2. All elements between tab(index1) and tab(index2) are used in the bind.

If you do not specify indexes in the bind call, and two different binds in a statement specify tables that contain a different number of elements, then the number of elements actually used is the minimum number between all tables. This is also the case if you specify indexes — the minimum range is selected between the two indexes for all tables.

Not all bind variables in a query have to be array binds. Some can be regular binds and the same value are used for each element of the collections in expression evaluations (and so forth).

See Also:

'Examples 3, 4, and 5: Bulk DML' for examples of how to bind collections.

Bulk Array Binds

Bulk selects, inserts, updates, and deletes can enhance the performance of applications by bundling many calls into one. The DBMS_SQL package lets you work on collections of data using the PL/SQL table type.

Table items are unbounded homogeneous collections. In persistent storage, they are like other relational tables and have no intrinsic ordering. But when a table item is brought into the workspace (either by querying or by navigational access of persistent data), or when it is created as the value of a PL/SQL variable or parameter, its elements are given subscripts that can be used with array-style syntax to get and set the values of elements.

The subscripts of these elements need not be dense, and can be any number including negative numbers. For example, a table item can contain elements at locations -10, 2, and 7 only.

When a table item is moved from transient workspace to persistent storage, the subscripts are not stored; the table item is unordered in persistent storage.

At bind time the table is copied out from the PL/SQL buffers into local DBMS_SQL buffers (the same as for all scalar types) and then the table is manipulated from the local DBMS_SQL buffers. Therefore, if you change the table after the bind call, then that change does not affect the way the execute acts.

Types for Scalar and LOB Collections

You can declare a local variable as one of the following table-item types, which are defined as public types in DBMS_SQL.

BIND_VARIABLE Procedures

This procedures binds a given value or set of values to a given variable in a cursor, based on the name of the variable in the statement.

Syntax

Where <datatype> can be any one of the following types:

Notice that BIND_VARIABLE is overloaded to accept different datatypes.

The following syntax is also supported for BIND_VARIABLE. The square brackets [] indicate an optional parameter for the BIND_VARIABLE function.

To bind CHAR, RAW, and ROWID data, you can use the following variations on the syntax:

See Also:

Oracle Database Application Developer's Guide - Large Objects

Pragmas

Parameters

Table 100-3 BIND_VARIABLE Procedure Parameters

ParameterDescription

c

ID number of the cursor to which you want to bind a value.

name

Name of the variable in the statement.

value

Value that you want to bind to the variable in the cursor.

For IN and IN/OUT variables, the value has the same type as the type of the value being passed in for this parameter.

out_value_size

Maximum expected OUT value size, in bytes, for the VARCHAR2, RAW, CHAROUT or IN/OUT variable.

If no size is given, then the length of the current value is used. This parameter must be specified if the value parameter is not initialized.


Usage Notes

If the variable is an IN or IN/OUT variable or an IN collection, then the given bind value must be valid for the variable or array type. Bind values for OUT variables are ignored.

The bind variables or collections of a SQL statement are identified by their names. When binding a value to a bind variable or bind array, the string identifying it in the statement must contain a leading colon, as shown in the following example:

For this example, the corresponding bind call would look similar to

The length of the bind variable name should be <=30 bytes.

For binding a range, the table must contain the elements that specify the range — tab(index1) and tab(index2) — but the range does not have to be dense. Index1 must be less than or equal to index2. All elements between tab(index1) and tab(index2) are used in the bind.

If you do not specify indexes in the bind call, and two different binds in a statement specify tables that contain a different number of elements, then the number of elements actually used is the minimum number between all tables. This is also the case if you specify indexes — the minimum range is selected between the two indexes for all tables.

Not all bind variables in a query have to be array binds. Some can be regular binds and the same value are used for each element of the collections in expression evaluations (and so forth).

See Also:

'Examples 3, 4, and 5: Bulk DML' for examples of how to bind collections.

Bulk Array Binds

Bulk selects, inserts, updates, and deletes can enhance the performance of applications by bundling many calls into one. The DBMS_SQL package lets you work on collections of data using the PL/SQL table type.

Table items are unbounded homogeneous collections. In persistent storage, they are like other relational tables and have no intrinsic ordering. But when a table item is brought into the workspace (either by querying or by navigational access of persistent data), or when it is created as the value of a PL/SQL variable or parameter, its elements are given subscripts that can be used with array-style syntax to get and set the values of elements.

The subscripts of these elements need not be dense, and can be any number including negative numbers. For example, a table item can contain elements at locations -10, 2, and 7 only.

When a table item is moved from transient workspace to persistent storage, the subscripts are not stored; the table item is unordered in persistent storage.

At bind time the table is copied out from the PL/SQL buffers into local DBMS_SQL buffers (the same as for all scalar types) and then the table is manipulated from the local DBMS_SQL buffers. Therefore, if you change the table after the bind call, then that change does not affect the way the execute acts.

Types for Scalar and LOB Collections

You can declare a local variable as one of the following table-item types, which are defined as public types in DBMS_SQL.

CLOSE_CURSOR Procedure

This procedure closes a given cursor.

Syntax

Pragmas

Parameters

Table 100-4 CLOSE_CURSOR Procedure Parameters

ParameterModeDescription

c

IN

ID number of the cursor that you want to close.

c

OUT

Cursor is set to null.

After you call CLOSE_CURSOR, the memory allocated to the cursor is released and you can no longer fetch from that cursor.


COLUMN_VALUE Procedure

This procedure returns the value of the cursor element for a given position in a given cursor. This procedure is used to access the data fetched by calling FETCH_ROWS.

Syntax

Where <datatype> can be any one of the following types:

Note:

Opera mini for java. It also saves time and effort thanks to features like shortcut keys and touchscreen control.This browser gives users access to their data wherever they are and whenever they need it. The latest version allows you to quickly browse the web, including secure encrypted websites or websites with several graphics. Opera Mini helps users browse the web from their mobile phones with comfort and speed.

The square brackets [ ] indicate optional parameters.

See Also:

Oracle Database Application Developer's Guide - Large Objects

Pragmas

The following syntax is also supported for the COLUMN_VALUE procedure:

Where the <table_variable> and its corresponding <datatype> can be any one of these matching pairs:

For columns containing CHAR, RAW, and ROWID data, you can use the following variations on the syntax:

Parameters

Table 100-5 COLUMN_VALUE Procedure Parameters

ParameterDescription

c

ID number of the cursor from which you are fetching the values.

position

Relative position of the column in the cursor.

The first column in a statement has position 1.

value

Returns the value at the specified column and row.

If the row number specified is greater than the total number of rows fetched, then you receive an error message.

Oracle raises exception ORA-06562, inconsistent_type, if the type of this output parameter differs from the actual type of the value, as defined by the call to DEFINE_COLUMN.

table_variable

Local variable that has been declared <datatype>.

column_error

Returns any error code for the specified column value.

actual_length

The actual length, before any truncation, of the value in the specified column.


Exceptions

inconsistent_type (ORA-06562) is raised if the type of the given OUT parameter value is different from the actual type of the value. This type was the given type when the column was defined by calling procedure DEFINE_COLUMN.

COLUMN_VALUE_LONG Procedure

This procedure gets part of the value of a long column.

Syntax

Pragmas

Parameters

Table 100-6 COLUMN_VALUE_LONG Procedure Parameters

ParameterDescription

c

Cursor ID number of the cursor from which to get the value.

position

Position of the column of which to get the value.

length

Number of bytes of the long value to fetch.

offset

Offset into the long field for start of fetch.

value

Value of the column as a VARCHAR2.

value_length

Number of bytes actually returned in value.


DEFINE_ARRAY Procedure

This procedure defines the collection for column into which you want to fetch rows (with a FETCH_ROWS call). This procedure lets you do batch fetching of rows from a single SELECT statement. A single fetch call brings over a number of rows into the PL/SQL aggregate object.

When you fetch the rows, they are copied into DBMS_SQL buffers until you run a COLUMN_VALUE call, at which time the rows are copied into the table that was passed as an argument to the COLUMN_VALUE call.

Scalar and LOB Types for Collections

You can declare a local variable as one of the following table-item types, and then fetch any number of rows into it using DBMS_SQL. (These are the same types as you can specify for the BIND_ARRAY procedure.)

Syntax

Where <table_variable> and its corresponding <datatype> can be any one of the following matching pairs:

Notice that DEFINE_ARRAY is overloaded to accept different datatypes.

Pragmas

The subsequent FETCH_ROWS call fetch 'count' rows. When the COLUMN_VALUE call is made, these rows are placed in positions indx, indx+1, indx+2, and so on. While there are still rows coming, the user keeps issuing FETCH_ROWS/COLUMN_VALUE calls. The rows keep accumulating in the table specified as an argument in the COLUMN_VALUE call.

Parameters

Table 100-7 DEFINE_ARRAY Procedure Parameters

ParameterDescription

c

ID number of the cursor to which you want to bind an array.

position

Relative position of the column in the array being defined.

The first column in a statement has position 1.

table_variable

Local variable that has been declared as <datatype>.

cnt

Number of rows that must be fetched.

lower_bnd

Results are copied into the collection, starting at this lower bound index.


The count (cnt) must be an integer greater than zero; otherwise an exception is raised. The indx can be positive, negative, or zero. A query on which a DEFINE_ARRAY call was issued cannot contain array binds.

See Also:

'Examples 6 and 7: Defining an Array' for examples of how to define collections.

DEFINE_COLUMN Procedure

This procedure defines a column to be selected from the given cursor. This procedure is only used with SELECT cursors.

The column being defined is identified by its relative position in the SELECT list of the statement in the given cursor. The type of the COLUMN value determines the type of the column being defined.

Syntax

Where <datatype> can be any one of the following types:

Notice that DEFINE_COLUMN is overloaded to accept different datatypes.

See Also:

Oracle Database Application Developer's Guide - Large Objects

Pragmas

The following syntax is also supported for the DEFINE_COLUMN procedure:

To define columns with CHAR, RAW, and ROWID data, you can use the following variations on the procedure syntax:

Parameters

Table 100-8 DEFINE_COLUMN Procedure Parameters

ParameterDescription

c

ID number of the cursor for the row being defined to be selected.

position

Relative position of the column in the row being defined.

The first column in a statement has position 1.

column

Value of the column being defined.

The type of this value determines the type for the column being defined.

column_size

Maximum expected size of the column value, in bytes, for columns of type VARCHAR2, CHAR, and RAW.


DEFINE_COLUMN_LONG Procedure

This procedure defines a LONG column for a SELECT cursor. The column being defined is identified by its relative position in the SELECT list of the statement for the given cursor. The type of the COLUMN value determines the type of the column being defined.

Syntax

Parameters

Table 100-9 DEFINE_COLUMN_LONG Procedure Parameters

ParameterDescription

c

ID number of the cursor for the row being defined to be selected.

position

Relative position of the column in the row being defined.

The first column in a statement has position 1.


DESCRIBE_COLUMNS Procedure

This procedure describes the columns for a cursor opened and parsed through DBMS_SQL.

Syntax

Parameters

Table 100-10 DESCRIBE_COLUMNS Procedure Parameters

ParameterDescription

c

ID number of the cursor for the columns being described.

col_cnt

Number of columns in the select list of the query.

desc_t

Table of DESC_REC, each DESC_REC describing a column in the query.


See Also:

'Example 8: Describe Columns' illustrates how to use DESCRIBE_COLUMNS.

DESCRIBE_COLUMNS2 Procedure

This function describes the specified column. This is an alternative to DESCRIBE_COLUMNS Procedure.

Syntax

Pragmas

Parameters

Table 100-11 DESCRIBE_COLUMNS2 Procedure Parameters

ParameterDescription

c

ID number of the cursor for the columns being described.

col_cnt

Number of columns in the select list of the query.

desc_tab2

The describe table to fill in with the description of each of the columns of the query. This table is indexed from one to the number of elements in the select list of the query.


EXECUTE Function

This function executes a given cursor. This function accepts the ID number of the cursor and returns the number of rows processed. The return value is only valid for INSERT, UPDATE, and DELETE statements; for other types of statements, including DDL, the return value is undefined and should be ignored.

Syntax

Parameters

Table 100-12 EXECUTE Function Parameters

ParameterDescription

c

Cursor ID number of the cursor to execute.


EXECUTE_AND_FETCH Function

This function executes the given cursor and fetches rows. This function provides the same functionality as calling EXECUTE and then calling FETCH_ROWS. Calling EXECUTE_AND_FETCH instead, however, may reduce the number of network round-trips when used against a remote database.

The EXECUTE_AND_FETCH function returns the number of rows actually fetched.

Syntax

Pragmas

Parameters

Table 100-13 EXECUTE_AND_FETCH Function Parameters

ParameterDescription

c

ID number of the cursor to execute and fetch.

exact

Set to TRUE to raise an exception if the number of rows actually matching the query differs from one.

Note: Oracle does not support the exact fetch TRUE option with LONG columns.

Even if an exception is raised, the rows are still fetched and available.


FETCH_ROWS Function

This function fetches a row from a given cursor. You can call FETCH_ROWS repeatedly as long as there are rows remaining to be fetched. These rows are retrieved into a buffer, and must be read by calling COLUMN_VALUE, for each column, after each call to FETCH_ROWS.

The FETCH_ROWS function accepts the ID number of the cursor to fetch, and returns the number of rows actually fetched.

Syntax

Pragmas

Parameters

Table 100-14 FETCH_ROWS Function Parameters

ParameterDescription

c

ID number.


IS_OPEN Function

This function checks to see if the given cursor is currently open.

Syntax

Pragmas

Parameters

Table 100-15 IS_OPEN Function Parameters

Calculate your Florida Driver's License number from your information. How it works. Reverse analyze an existing number. Information about the generator of US SSN, Driver License, State ID, Passport, and Tax ID numbers and data This tool generates information from algorithms, it does not produce actual issued documents nor facsimiles, specimen or samples of real documents. It's not meant for driving, FLVS driver's ed, insurance, or any other official use. Florida drivers license number generator online. It is truly a top rated Fake License Generator. Fake id cc, fake student id, fake id card, fake id card generator, fake id driving licence, my fake id, fake driving license, make a fake id online Legaldoc- Solution is really an acclaimed company all over the world for serving people in such a most unique way.

ParameterDescription

c

Cursor ID number of the cursor to check.


Return Values

Table 100-16 IS_OPEN Function Return Values

Return ValueDescription

TRUE

Given cursor is currently open.

FALSE

Given cursor is currently not open.


LAST_ERROR_POSITION Function

This function returns the byte offset in the SQL statement text where the error occurred. The first character in the SQL statement is at position 0.

Syntax

Pragmas

Usage Notes

Call this function after a PARSE call, before any other DBMS_SQL procedures or functions are called.

LAST_ROW_COUNT Function

This function returns the cumulative count of the number of rows fetched.

Syntax

Pragmas

Usage Notes

Call this function after a FETCH_ROWS or an EXECUTE_AND_FETCH call. If called after an EXECUTE call, then the value returned is zero.

LAST_ROW_ID Function

This function returns the ROWID of the last row processed.

Syntax

Pragmas

Usage Notes

Call this function after a FETCH_ROWS or an EXECUTE_AND_FETCH call.

LAST_SQL_FUNCTION_CODE Function

This function returns the SQL function code for the statement. These codes are listed in the Oracle Call Interface Programmer's Guide.

Syntax

Pragmas

Usage Notes

You should call this function immediately after the SQL statement is run; otherwise, the return value is undefined.

OPEN_CURSOR Function

This procedure opens a new cursor. When you no longer need this cursor, you must close it explicitly by calling CLOSE_CURSOR.

You can use cursors to run the same SQL statement repeatedly or to run a new SQL statement. When a cursor is reused, the contents of the corresponding cursor data area are reset when the new SQL statement is parsed. It is never necessary to close and reopen a cursor before reusing it.

Syntax

Pragmas

Return Values

This function returns the cursor ID number of the new cursor.

PARSE Procedure

This procedure parses the given statement in the given cursor. All statements are parsed immediately. In addition, DDL statements are run immediately when parsed.

There are two versions of the PARSE procedure: one uses a VARCHAR2 statement as an argument, and the other uses a VARCHAR2S (table of VARCHAR2) as an argument.

Syntax

The PARSE procedure also supports the following syntax for large SQL statements:

Note:

The procedure concatenates elements of a PL/SQL table statement and parses the resulting string. You can use this procedure to parse a statement that is longer than the limit for a single VARCHAR2 variable by splitting up the statement.

Parameters

Table 100-17 PARSE Procedure Parameters

ParameterDescription

c

ID number of the cursor in which to parse the statement.

statement

SQL statement to be parsed.

Unlike PL/SQL statements, your SQL statement should not include a final semicolon. For example:

DBMS_SQL.PARSE(cursor1, 'BEGIN proc; END;', 2);

DBMS_SQL.PARSE(cursor1, 'INSERTINTO tab VALUES(1)', 2);

lb

Lower bound for elements in the statement.

ub

Upper bound for elements in the statement.

lfflg

If TRUE, then insert a linefeed after each element on concatenation.

language_flag

Determines how Oracle handles the SQL statement. The following options are recognized:

  • V6 (or 0) specifies version 6 behavior.

  • NATIVE (or 1) specifies normal behavior for the database to which the program is connected.

  • V7 (or 2) specifies Oracle database version 7 behavior.


Usage Notes

Note:

Using DBMS_SQL to dynamically run DDL statements can result in the program hanging. For example, a call to a procedure in a package results in the package being locked until the execution returns to the user side. Any operation that results in a conflicting lock, such as dynamically trying to drop the package before the first lock is released, results in a hang.

The size limit for parsing SQL statements with the preceding syntax is 32KB.

Note:

Because client-side code cannot reference remote package variables or constants, you must explicitly use the values of the constants.

Download Oracle 11g Database

For example, the following code does not compile on the client:

DBMS_SQL.PARSE(cur_hdl, stmt_str, DBMS_SQL.V7); -- uses constant DBMS_SQL.V7

The following code works on the client, because the argument is explicitly provided:

DBMS_SQL.PARSE(cur_hdl, stmt_str, 2); -- compiles on the client

Examples

To parse SQL statements larger than 32 KB, DBMS_SQL makes use of PL/SQL tables to pass a table of strings to the PARSE procedure. These strings are concatenated and then passed on to the Oracle server.

You can declare a local variable as the VARCHAR2S table-item type, and then use the PARSE procedure to parse a large SQL statement as VARCHAR2S.

The definition of the VARCHAR2S datatype is:

Exceptions

If you create a type/procedure/function/package using DBMS_SQL that has compilation warnings, an ORA-24344 exception is raised, and the procedure is still created.

VARIABLE_VALUE Procedures

This procedure returns the value of the named variable for a given cursor. It is used to return the values of bind variables inside PL/SQL blocks or DML statements with returning clause.

Syntax

Where <datatype> can be any one of the following types:

The following syntax is also supported for the VARIABLE_VALUE procedure:

Database Management System

Where the <table_variable> and its corresponding <datatype> can be any one of these matching pairs:

For variables containing CHAR, RAW, and ROWID data, you can use the following variations on the syntax:

Pragmas

Parameters

Table 100-18 VARIABLE_VALUE Procedure Parameters

ParameterDescription

c

ID number of the cursor from which to get the values.

name

Name of the variable for which you are retrieving the value.

value

Returns the value of the variable for the specified position.

Oracle raises exception ORA-06562, inconsistent_type, if the type of this output parameter differs from the actual type of the value, as defined by the call to BIND_VARIABLE.

position

Relative position of the column in the cursor.

The first column in a statement has position 1.


Oracle 10g is a powerful enterprise-level relational database engine (DBMS) for storing any kind of data while development, deployment, and distributing applications. This free download is the standalone offline setup of Oracle 10g Express Edition for Windows 32-bit and 64-bit.

Oracle 10g Overview

When developing an application you always need to store the data and the properties of the application. Oracle 10g is the most reliable relational database model, which means that you need to maintain the relations and keys while storing data. Most of the enterprises prefer to use Oracle database engine as it provides a scalable environment to fulfill all the business needs. The environment is very friendly for the starters as well as the experts. It provides a GUI along with command-line support for scripting. The popularity of this database engine is also due to its security features. You can easily add access rights and prevent data from unauthorized access.

Moreover, it is a very lightweight database management system which has no effect on the performance of the system and the application relying on it. Automatic recovering from errors makes it a stable environment as compared to other database engines. If you are looking for a relational database engine for any level of project, we suggest you Oracle DBMS as due to its advanced scalability and reliability factors.

Features of Oracle 10g

Some of the features of Oracle RDBMS 10g are:

  • User-friendly environment
  • Light on system resources
  • Relational databse management system
  • Grid management and computing
  • Scalability features
  • Servers manangement
  • Workspace options
  • Clustering features
  • Scalable and reliable DBMS

System Requirements for Oracle 10g

Before you download Oracle RDBMS 10g, make sure that your system meets the given requirements.

  • Operating System: Windows XP/Vista/7/8/10
  • Free Hard Disk Space: 1 GB of minimum free hard disk space required
  • Installed Memory: 512 MB of minimum RAM required
  • Processor: Single Core processor or higher

Oracle 10g Free Download

Click on the below link to download the standalone setup of Oracle 10g for Windows x86 and x64 architecture. It is the best enterprise level database management system with all the required configurations.