The examples provided here are divided by chapter, and match those found in
the book. Each chapter contains a script to create the schema with all necessary
permissions. The permissions granted for the schemas change between chapters,
so be sure to run the schema creation script for each chapter and not rely on
the one created in another chapter. To avoid permissions problems it is highly
recommended that the schema creation script we provide be used, but you may
also create your own schema as long as all required privileges are granted.
The examples for each chapter are created to run independent of objects created
in other chapters. In other words - no cross-chapter dependencies. This means
you can jump from chapter 10 to 17, and have no problem running chapter 17's
examples.
When creating your database, be sure to install Oracle Text as it is used for
examples in multiple chapters. If not installed, some examples will not work
and you will receive errors on schema creation. Oracle Text is included in both
Standard and Enterprise editions, so either release can be used.
All examples were tested on Windows and Linux ports of Oracle 10g Release 1.
Should you have ANY problem with the examples, feel free to e-mail FEEDBACK@PLSQLBOOK.COM,
and we will respond to the issue promptly.
| CreateUser.sql |
This script creates the plsql user for chapter 3 examples. You must run
this script as SYS or SYSTEM as SYSDBA. The script can be rerun. |
| AnonymousBlock.sql |
This script demonstrates the structure of an anonymous block. |
| BindVariables.sql |
This script demonstrates the use of bind variables. |
| BlockStructure.sql |
This script demonstrates the structure of a block. |
| Boolean.sql |
This script demonstrates how to assign a value to a variable of type boolean. |
| BooleanLiteral.sql |
This script demonstrates Boolean literals. |
| Case.sql |
This script demonstrates CASE. |
| CompileError.sql |
This script demonstrates the compile time warnings generated by Oracle. |
| CompileWarning.sql |
This script demonstrates the DBMS_WARNING package. |
| DateTimeLiteral.sql |
This script demonstrates Date/Time literals. |
| Goto.sql |
This script demonstrates the GOTO command. |
| If.sql |
This script demonstrates IF-THEN, IF-THEN-ELSE, and IF-THEN-ELSIF. |
| Interval.sql |
This script demonstrates the use of the INTERVAL types. |
| Loop.sql |
This script demonstrates LOOPs. |
| MultiLineComment.sql |
This script demonstrates the use of multi-line comment blocks. |
| NamedBlock.sql |
This script demonstrates the structure of a named block. |
| NestedBlock.sql |
This script demonstrates a nested block. |
| Number.sql |
This script demonstrates the NUMBER datatype. |
| PLSQL_Warnings.sql |
This script demonstrates the PLSQL_WARNINGS parameter. |
| Ref_Cursor.sql |
This script demonstrates the use of REF CURSOR. |
| Reserved.sql |
This script prints a list of reserved words. |
| SingleLineComment.sql |
This script demonstrates the use of single line comments. |
| StringLiteral.sql |
This script demonstrates the different ways in which 10g handles apostrophes. |
| Timestamp.sql |
This script demonstrates the TIMESTAMP datatypes. |
| Trigger.sql |
This script demonstrates the use of a trigger. |
| Variables.sql |
This script declares a variable as a constant then attempts to change
the assigned value. |
| Visibility.sql |
This script demonstrates variable visibility. |
| WhiteSpace.sql |
This script demonstrates shows poor design when white space is not used. |
| WrapAfter.plb |
This file shows what a wrapped file looks like. |
| WrapBefore.sql |
This file is used in the example showing how to wrap PL/SQL. |
| WrapSeed.sql |
This script demonstrates the Wrap utility. |
| CreateUser.sql |
This script creates the plsql user for chapter 4 examples.
You must run this script as SYS or SYSTEM as SYSDBA. The script can be rerun. |
| Autonomous.sql |
This script demonstrates how autonomous transactions work. |
| BasicSelect.sql |
This script demonstrates how to use a basic select statement in a PL/SQL
block. |
| ContextArea1.sql |
This script shows how cursors work with the context area, and remain consistent
after opened. |
| ContextArea2.sql |
This script demonstrates how changes to the database impact processing
of records after a cursor is opened. |
| Conversion.sql |
This script demonstrates the TO_CHAR and TO_DATE conversion functions. |
| CursorForLoop.sql |
This script demonstrates the use of the Cursor For Loop. |
| CursorSubquery.sql |
This script demonstrates the use of the cursor subquery. |
| CursorVariable1.sql |
This script demonstrates the use of REF CURSOR. |
| CursorVariable2.sql |
This script demonstrates the use of SYS_REFCURSOR. |
| DateTime.sql |
This script demonstrates a few date functions. |
| DDL.sql |
This script demonstrates how DDL doesn't work with PL/SQL. |
| Delete.sql |
This script demonstrates how DELETEs work with PL/SQL. |
| Error.sql |
This script demonstrates error functions SQLERRM and SQLCODE. |
| ExplicitAttribute.sql |
This script demonstrates the use of cursor attributes. |
| GreatestLeast.sql |
This script demonstrates the Greatest and Least functions. |
| ImplicitAttribute.sql |
This script demonstrates the use of cursor attributes. |
| Insert.sql |
This script demonstrates how INSERTs work with PL/SQL. |
| Level.sql |
This script shows the pseudocolumn LEVEL and an example of using the levels.
|
| LevelUpdate.sql |
This script shows the pseudocolumn LEVEL and an example of using the levels
with an update. |
| Like.sql |
This script demonstrates the use of the LIKE operator. |
| LockSession1.sql |
This script demonstrates how transactions use locks, commits, and rollbacks.
This script is for the first session as noted in the book. |
| LockSession2.sql |
This script demonstrates how transactions use locks, commits, and rollbacks.
This script is for the second session as noted in the book. |
| Lower.sql |
This script demonstrates the LOWER function. |
| NDS.sql |
This script demonstrates how NDS works with PL/SQL. |
| OpenCursor.sql |
This script demonstrates what happens when the number of cursors opened
exceeds the open_cursors value. For this example, set the value of open_cursors
to 20 in the init.ora file. |
| RegexpLike.sql |
This script demonstrates the use of the REGEXP_LIKE function. |
| Round.sql |
This script demonstrates the ROUND function. |
| RowID.sql |
This script demonstrates the use of the rowid pseudo column. |
| Savepoint.sql |
This script demonstrates how transactions use savepoints. |
| SimpleLoop.sql |
This script shows how simple loops are written. |
| TextIndex.sql |
This script demonstrates indexing using Oracle Text. |
| Update.sql |
This script demonstrates how UPDATEs work with PL/SQL. |
| UpdateDual.sql |
This script demonstrates how DML works with PL/SQL. |
| WhereCurrentOf.sql |
This script demonstrates how UPDATEs work with PL/SQL and the WHERE CURRENT
OF clause. |
| WhileLoop.sql |
This script demonstrates the use of the WHILE loop. |
| create_addressbook1.sql |
This script builds objects for the example with standard Oracle data types. |
| create_function1.sql |
This script demonstrates using a record type as a function return value. |
| create_function2.sql |
This script demonstrates using an object type as a function return value. |
| create_function2e.sql |
This script demonstrates using an object type can not be assigned a %ROWTYPE record type. |
| create_record1.sql |
This script demonstrates using a record type to populate a table. |
| create_record2.sql |
This script demonstrates using explicit definition to define a record type. |
| create_record3.sql |
This script demonstrates using explicit definition to define record
types and a compound record type; and, the use of nested types. |
| create_record4.sql |
This script demonstrates using a database object to define a record type. |
| create_record5.sql |
This script demonstrates using compound database objects to define a record type. |
| create_record6.sql |
This script demonstrates using explicit definition to define record types and a compound record type; and, the use of nested types. |
| create_record7.sql |
This script demonstrates passing database objects as actual parameters to a procedure. |
| create_user.sql |
This script verifies and defines the PLSQL user. |
| query_record1.sql |
This script verifies the success of the following programs.
- create_record1.sql
- create_record2.sql
- create_record3.sql |
| bulk_collect1.sql |
This script demonstrates how to do a bulk collect into an associative array. |
| bulk_collect2.sql |
This script demonstrates how to do a bulk collect into a nested table. |
| bulk_collect3.sql |
This script demonstrates how to do a non-bulk select into elements of a PL/SQL table. |
| count.sql |
This script demonstrates how to use the Oracle10g Collection API COUNT method against an element. |
| create_addressbook2.sql |
This script builds objects for the example with standard Oracle data types
in all but one column. It uses a varray of VARCHAR2(30 CHAR) for the
ADDRESSES.STREET_ADDRESS column. |
| create_addressbook2e.sql |
This script builds objects for the example with standard Oracle data types in all but one column. |
| create_addressbook3.sql |
This script builds objects for the example with standard Oracle data types
in all but one column. |
| create_addressbook3e.sql |
This script builds objects for the example with standard Oracle data types
in all but one column. |
| create_assocarray1.sql |
This script builds an associative array. |
| create_assocarray2.sql |
This script demonstrates you cannot traverse an associative array until elements are initialized. |
| create_assocarray3.sql |
This script demonstrates you can avoid traversing an associative array
where no elements are initialized. |
| create_assocarray4.sql |
This script demonstrates you cannot use the Collection API EXTEND method
to allocated space. |
| create_assocarray5.sql |
This script demonstrates initialization and assignment with a numeric
index value to an associative array. |
| create_assocarray5e.sql |
This script demonstrates initialization and assignment with a numeric
index value to an associative array. |
| create_assocarray6.sql |
This script demonstrates initialization and assignment with a unique
string index value to an associative array. |
| create_nestedtable1.sql |
This defines a three element nested table built with a three item constructor of null values. |
| create_nestedtable2.sql |
This constructs a null element nested table, then extends it one element at a time. |
| create_nestedtable3.sql |
This constructs a null element nested table type in the database, then extends it
one element at a time. |
| create_nestedtable4.sql |
This constructs a two varrays and one nested table type in the database,
then it assigns the contents of the varrays into a nested table. |
| create_user.sql |
This script verifies and defines the PLSQL user. |
| create_varray1.sql |
This defines a varray with a three element constructor of null elements. |
| create_varray2.sql |
This defines a varray with a null element constructor and extends it one element at a time. |
| create_varray3.sql |
This defines a varray with a three element constructor of null elements and attempt to populate it beyond three elements. |
| create_varray4.sql |
This defines a varray with a null element constructor and extends it one element at a time
by a formula. |
| delete.sql |
This script demonstrates how to use the Oracle10g Collection API
DELETE method against a set of elements. |
| exists.sql |
This script demonstrates how to use the Oracle10g Collection API
EXISTS method against an element. |
| extend.sql |
This script demonstrates how to use the Oracle10g Collection API
EXTEND method against an element. |
| first.sql |
This script demonstrates how to use the Oracle10g Collection API
FIRST and LAST methods against a collection. |
| limit.sql |
This script demonstrates how to use the Oracle10g Collection API
LIMIT method against a collection. |
| nestedtable_dml1.sql |
This script demonstrates using a stored function to resolve the
one-to-many relation of a nested table in a row of data. |
| nestedtable_dml2.sql |
This script demonstrates how to update nested tables. |
| nestedtable_dml3.sql |
This script demonstrates the update of an element of a nested table
collection. |
| nestedtable_dml4.sql |
This script demonstrates the update of an element of a nested table
collection. |
| trim.sql |
This script demonstrates how to use the Oracle10g Collection API
TRIM method against a collection. |
| varray_dml1.sql |
This script inserting and reading from a varray. |
| varray_dml2.sql |
This script demonstrates how to update varrays. |
| varray_dml3.sql |
This script demonstrates the update of an element of a varray
collection. |
| varray_dml4.sql |
This script demonstrates the update of an element of a varray
collection. |
For this set of examples, make sure you run tables.sql after creating the schema.
All other example scripts depend on the objects created in tables.sql.
| CreateUser.sql |
This script creates the plsql user for chapter 7 examples.
You must run this script as SYS or SYSTEM as SYSDBA. The script can be rerun. |
| autoRollback.sql |
This script demonstrates how the server will roll back the current transaction
if the top level block exits with an unhandled exception. |
| DuplicateHandlers.sql |
This example illustrates the PLS-483 error. |
| DupValOnIndex.sql |
This block will raise the DUP_VAL_ON_INDEX exception. |
| ExceptionInit.sql |
This script demonstrates the EXCEPTION_INIT pragma. |
| OutOfScope.sql |
This script demonstrates the scope of exceptions. |
| SQLERRM.sql |
This script demonstrates the use of SQLERRM. |
| tables.sql |
This script creates the tables and data used by other examples in this
chapter. |
| UserDefined.sql |
This script demonstrates user defined exceptions. |
| VerifyAuthors.sql |
This procedure demonstrates the use of RAISE_APPLICATION_ERROR. |
For this set of examples, make sure you run tables.sql after creating the schema.
All other example scripts depend on the objects created in tables.sql.
| CreateUser.sql |
This script creates the plsql user for chapter 8 examples.
You must run this script as SYS or SYSTEM as SYSDBA. The script can be rerun. |
| AddNewAuthor.sql |
This script demonstrates how to create and call a simple procedure. |
| AddNewBook.sql |
This procedure will insert a new book into the books table. It also demonstrates
default parameters. |
| callANA.sql |
This block illustrates how to call the AddNewAuthor function. |
| CallMe.sql |
This script demonstrates positional vs. named parameter passing. |
| calls.sql |
This script demonstrates the use of the CALL statement. |
| callSL.sql |
This block illustrates how to call a packaged procedure which takes a
named type parameter. |
| CopyFast.sql |
This package illustrates the possible speed benefits of NOCOPY. |
| InventoryOps.sql |
This script demonstrates a package. |
| InventoryOps2.sql |
This version of the InventoryOps package contains an extra procedure in
the package body. |
| NoCopyTest.sql |
This script illustrates the behavior of NOCOPY. |
| noparams.sql |
This procedure and function demonstrate the syntax of calling subprograms
with no parameters. |
| objectOverload.sql |
This script demonstrates overloading based on user defined object types. |
| overload.sql |
This version of InventoryOps demonstrates an overloaded procedure, StatusList. |
| packageError.sql |
This package will not compile because the specification and body do not
match. |
| ParameterLength.sql |
This script illustrates constraints on formal parameters. |
| parameterModes.sql |
These procedures are used to demonstrate the behavior of IN, OUT, and
IN OUT parameter modes. |
| RaiseError.sql |
This script shows the behavior of exceptions raised within subprograms. |
| Random.sql |
This illustrates package initialization. |
| tables.sql |
This script creates the tables and data used by other examples in this
chapter. |
| ThreeAuthors.sql |
This script demonstrates a function and how to call it. |
| create_messages_table.sql |
This script builds table an object for DBMS_ALERT triggers. |
| create_messenger.sql |
This script sends builds a package to send and receive
messages between users. |
| create_pipe1.sql |
This script deletes a pipe if it exists in the context of the current
session, then recreates it. |
| create_pipe2.sql |
This script deletes a pipe if it exists in the context of the current
session, then recreates it. |
| create_pipe3.sql |
This script deletes a pipe if it exists in the context of the current
session, recreates it, sends a message and retrieves a message from the pipe. |
| create_pipe4.sql |
This script deletes a pipe if it exists in the context of the current
session, recreates a private pipe, sends a message and retrieves a message
from the pipe. |
| create_signal_trigger.sql |
This script builds a trigger DBMS_ALERT signals on events
to the MESSAGES table. |
| create_user.sql |
This script verifies and defines the PLSQL user. It should be run
as the SYSTEM user or a user that has the DBA privilege role and
EXECUTE with grant option on DBMS_PIPE. |
| next_item_type1.sql |
This script tests DBMS_PIPE for a private pipe. |
| read_local.sql |
This script uses DBMS_PIPE to write a local message to
the implicit anonymous session pipe. |
| read_local_error.sql |
This script uses DBMS_PIPE to write a local message to
the implicit anonymous session pipe. |
| read_pipe.sql |
This script unpacks the local buffer. |
| read_pipe.sql |
This script write three messages to a private or public
pipe by using the DBMS_PIPE package. |
| register_interest.sql |
This script registers interest in a DBMS_ALERT
to the MESSAGES table. |
| insert_message.sql |
This script inserts, updates and deletes a row, triggering
three alerts. |
| use_messenger.sql |
This script demonstrates MESSENGER as a wrapper for the
DBMS_PIPE package. |
| waitone.sql |
This script waits for a DBMS_ALERT alert, which is
triggered on DML to the MESSAGES table. |
| write_local.sql |
This script uses DBMS_PIPE to write a local message to
the implicit anonymous session pipe. |
| write_pipe.sql |
This script write three messages to a private or public
pipe by using the DBMS_PIPE package. |
| create_javalib1.sql |
This script demonstrates how to build a Java library wrapper. |
| create_library1.sql |
This script demonstrates how to create a library for an external procedure. |
| create_library2.sql |
This script demonstrates how to create a library for
an external procedure for a poorly C program that
fails to match the signature of the PL/SQL library. |
| create_user.sql |
This script verifies and defines the PLSQL user. It should be run
as the SYSTEM user or a user that has the DBA privilege role and
EXECUTE with grant option on DBMS_PIPE. |
| listener1.ora |
Standard single listener shell for listener.ora file. |
| listener2.ora |
Standard two listener shell for listener.ora file.
The extproc IPC listener is separated. |
| listener3.ora |
Standard two listener shell for listener.ora file.
The extproc IPC listener is separated and ENV accesses
multiple DDL paths |
| ReadFile1.java |
This script demonstrates how to read a file in Java.
It is designed as a Java library file for an Oracle
database stored library. |
| tnsnames1.ora |
Standard single listener shell for tnsnames.ora file. |
| tnsnames2.ora |
Standard two listener shell for tnsnames.ora file.
The extproc IPC listener is separated. |
| tnsnames3.ora |
Standard two listener shell for tnsnames.ora file.
The extproc IPC listener is separated. |
| writestr1.c |
This script opens a file and write a single line
of text to the file. It is used in conjunction
with the create_library1.sql script. |
| writestr2.c |
This script opens a file and write a single line
of text to the file. It is used in conjunction
with the create_library2.sql script. |
| create_types.sql |
This is build types to test the Native Dynamic SQL package. |
| create_user.sql |
This script verifies and defines the PLSQL user. It should be run
as the SYSTEM user or a user that has the DBA privilege role and
EXECUTE with grant option on DBMS_PIPE. It also has grants needed
by the DMBS_SQL package. |
| dbms_sql.sql |
This is designed as a working tutorial of the Oracle
Built-in DBMS_SQL with examples of the for key methods. |
| dbms_sql_01.sql |
This is designed to test the DBMS_SQL_TUTORIAL package. |
| dbms_sql_02.sql |
This is designed to test the DBMS_SQL_TUTORIAL package. |
| dbms_sql_03.sql |
This is designed to test the DBMS_SQL_TUTORIAL package. |
| nds_null.sql |
This is designed to demonstrate managing a null value. |
| nds_sql.sql |
This is designed to test the Native Dynamic SQL package. |
| nds_sql_01.sql |
This is designed to test the Native Dynamic SQL package. |
| nds_sql_02.sql |
This is designed to test the Native Dynamic SQL package. |
| nds_sql_03.sql |
This is designed to test the Native Dynamic SQL package. |
| nds_sqle.sql |
This is designed as a working tutorial of the Oracle
Native Dynamic SQL (NDS) with an error in an OUT mode
parameter. It will compile successfully and raise a
runtime exception. |
| CreateUser.sql |
This script creates the plsql user for chapter 15 examples.
You must run this script as SYS or SYSTEM as SYSDBA. The script can be rerun. |
| AttributeChain.sql |
This script demonstrates attribute chaining. |
| ColObj.sql |
This script demonstrates column objects. |
| ForwardDeclaration.sql |
This script demonstrates forward type declarations. |
| Inheritance.sql |
This script demonstrates object type inheritance. |
| IsDangling.sql |
This script demonstrates how to handle dangling REFs. |
| IsOf.sql |
This script demonstrates the IS OF type statement. |
| ObjectTable.sql |
This script demonstrates the creation of an object table, and includes
an anonymous block to demonstrate DML operations against an object table. |
| ObjectView.sql |
This script demonstrates object view creation. |
| ObjMaintain.sql |
This script demonstrates type evolution. |
| RefObj.sql |
This script demonstrates object references using REF. |
| Treat.sql |
This script demonstrates the TREAT function. |
| UtlRef.sql |
This script demonstrates the UTL_REF package. |