When issuing a data manipulation (DML) statement in PL/SQL, there aresome situations when the value of a variable is undefined after the statementis executed. These include:If a FETCH or SELECT statement raises any exception, thenthe values of the define variables after that statement are undefined.If a DML statement affects zero rows, the values of the OUTbinds after the DML executes are undefined. This does not apply to a BULKor multirow operation.
Transaction Control
Oracle is transaction oriented; that is, Oracle uses transactions to ensure data integrity. Atransaction is a series of SQL data manipulation statements that does a logical unit of work.For example, two UPDATE statements might credit one bank account and debit another. It isimportant not to allow one operation to succeed while the other fails.At the end of a transaction that makes database changes, Oracle makes all the changespermanent or undoes them all. If your program fails in the middle of a transaction, Oracledetects the error and rolls back the transaction, restoring the database to its former state.You use the COMMIT, ROLLBACK, SAVEPOINT, and SET TRANSACTION commands tocontrol transactions. COMMIT makes permanent any database changes made during thecurrent transaction. ROLLBACK ends the current transaction and undoes any changes madesince the transaction began. SAVEPOINT marks the current point in the processing of atransaction. Used with ROLLBACK, SAVEPOINT undoes part of a transaction. SETTRANSACTION sets transaction properties such as read-write access and isolation level.See"Overview of Transaction Processing in PL/SQL".
SQL Functions
Example 6-4shows some queries that call SQL functions.Example 6-4 Calling the SQL COUNT Function in PL/SQLDECLAREjob_count NUMBER;emp_count NUMBER;BEGINSELECT COUNT(DISTINCT job_id) INTO job_count FROM employees;SELECT COUNT(*) INTO emp_count FROM employees;END;/
SQL Pseudocolumns
PL/SQL recognizes the SQL pseudocolumns CURRVAL, LEVEL, NEXTVAL, ROWID, andROWNUM. However, there are limitations on the use of pseudocolumns, including the