About the Object Iron Packages

The Object Iron is a set of database packages that helps you to access tables containing instances of Oracle8 object types. The packages generate a table-specific package, which you then use to access data from the specified table.

After generation, the table-specific package appears under the Stored Program Units node in the Object Navigator. This package contains procedures that allow you to select, insert, update, delete and lock records in the specified table. You can view and modify the code, if required. The generated table-specific package is particularly useful for creating a Forms data block that uses stored procedures .

You must have certain privileges to use the Object Iron packages to build a table-specific package. In addition, the tables need to meet certain conditions.


Installing the Object Iron Packages

You can install the Object Iron packages from the Interpreter in Procedure Builder or from SQL*Plus.

To install from Procedure Builder:

1	Choose File [image] Connect to log in to the database.

Use the schema name where the object table is located as the username.

2	Choose File [image] Interpret to run the genpkgs.pld script in the Interpreter.

The script creates the packages OPB_O8API and OPB_OBJ on the server-side and the procedure OBJIRON on the client side.

To install from SQL*Plus:

1	Log in to the database.

2	Type genpkgs.sql at the prompt.

The script creates the packages OPB_O8API and OPB_OBJ, and the procedure OBJIRON on the server side.

The OPB_OBJ package contains the methods for creating and removing a table-specific package. The OPB_O8API package does not have subprograms available for external use. It is used internally by Developer/2000.


Building and using a table-specific package

You must install the Object Iron packages before you can build any table-specific package.

To build a table-specific package:

  Run the OBJIRON procedure for each table you want to access.

For example:

  PL/SQL> OBJIRON('TABLENAME', 'OWNERNAME');

where TABLENAME is the table you want to access, and OWNERNAME is the owner of the table.

In the example, the OBJIRON procedure builds a package with the name OPB$TABLENAME.

Note:  The maximum length of the generated package name is 30 characters. If the name of the table exceeds 30 characters, only the first 26 characters are used in the generated package name because the procedure adds the prefix OPB$ to each package name.

Using a table-specific package

The OBJIRON procedure builds a table-specific package containing five procedures. In the example, the generated package is OPB$TABLENAME, and the procedures in the package are:

OPB$TABLENAME.O_Select
OPB$TABLENAME.O_Insert
OPB$TABLENAME.O_Update
OPB$TABLENAME.O_Delete
OPB$TABLENAME.O_Lock

When calling a procedure in your code, be sure to preface it with the appropriate package name.

The OBJIRON procedure provides a convenient wrapper for invoking the Object Iron packages. You may insert a customized WHERE clause to filter the data returned by O_Select or you may change the O_Lock WAIT/NOWAIT flag by modifying the procedure. For more information about the WAIT/NOWAIT flags, see your Oracle7 SQL Reference Guide.


Dropping a table-specific package

When you no longer need a table-specific package, run the OPB_OBJ.drp procedure. For example:

  PL/SQL> OPB_OBJ.drp ('TABLENAME', 'OWNERNAME');

where TABLENAME is the table you want to drop, and OWNERNAME is the owner of the table.

This procedure executes the 'DROP PACKAGE OPB$TABLENAME' statement, which deletes the associated packages from the database and releases the memory allocated to them.


Creating a Forms data block based on a table-specific package

Creating a Forms data block based on a table-specific package is similar to creating a data block based on a set of stored procedures.

When selecting a stored procedure as the data source for your data block, be sure to specify the exact procedure name with the appropriate package name prefix. For example, when you access the table TABLENAME via the package OPB$TABLENAME, use the following procedures for the desired action in the data block:

•	 procedure OPB$TABLENAME.O_Select for queries

•	procedure OPB$TABLENAME.O_Insert for inserting records

•	procedure OPB$TABLENAME.O_Update for updating records

•	procedure OPB$TABLENAME.O_Delete for deleting records

•	procedure OPB$TABLENAME.O_Lock for locking records


Privileges and conditions for using the Object Iron packages

Privileges

The owner of the object table must have the CREATE ANY PROCEDURE privilege to use the Object Iron packages to build a table-specific package. The system administrator grants this privilege.

Conditions

The object table from which you want to build a package must meet the following conditions:

•	The table can contain simple composite objects and REFs only. The Object Iron interface does not support RAW, LONG RAW, CLOB, BLOB, LOB, NESTED TABLES or VARRAYs.

•	All the composite object types that are referenced by the columns in the table must belong in the same schema as the table.