Skip to Main Content
Oracle PL/SQL Programming: A Developer's Workbook
book

Oracle PL/SQL Programming: A Developer's Workbook

by Steven Feuerstein, Andrew Odewahn
May 2000
Intermediate to advanced content levelIntermediate to advanced
594 pages
11h 32m
English
O'Reilly Media, Inc.
Content preview from Oracle PL/SQL Programming: A Developer's Workbook

Expert

Q:

11-25.

You can either use dynamic SQL (DBMS_SQL prior to Oracle 8.1 or native dynamic SQL from 8.1 onwards) to execute a dynamic PL/SQL block. You can also take advantage of the SAVEPOINT procedure in the DBMS_STANDARD package as shown in this rewrite:

BEGIN
   DBMS_STANDARD.SAVEPOINT ('start_process');
   INSERT INTO ...;
   DELETE FROM ...;

Q:

11-26.

You can set a savepoint in any of these ways:

  • SAVEPOINT savepoint;

  • DBMS_TRANSACTION.SAVEPOINT savepoint;

  • DBMS_STANDARD.SAVEPOINT savepoint;

  • Through the use of DBMS_SQL

Q:

11-27.

You can roll back your transaction in PL/SQL in any of these ways:

  • ROLLBACK;

  • DBMS_TRANSACTION.ROLLBACK_SAVEPOINT savepoint;

  • DBMS_STANDARD.ROLLBACK_SV savepoint;

  • Dynamic SQL (DBMS_SQL or native dynamic SQL in Oracle 8.1)

  • Unhandled exception

Q:

11-28.

When you execute this code, you get the following error:

ORA-01086: savepoint 'START_PROCESS' never established

At first glance this doesn’t make sense. You set the savepoint and then try to roll back to that savepoint. Unfortunately, Oracle doesn’t consider them to be the same savepoint. If you are going to set a savepoint by using the DBMS_STANDARD.SAVEPOINT program, you must roll back to that savepoint by calling another DBMS_STANDARD program:

BEGIN
   DBMS_STANDARD.SAVEPOINT ('start_process');
   DBMS_STANDARD.ROLLBACK_SV ('start_process');
END;

Q:

11-29.

Each time you issue a COMMIT in your session, the rollback segment is set back to the default for your session. You must, therefore, be careful to reset the current rollback segment back ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Oracle Database 12c PL/SQL Programming

Oracle Database 12c PL/SQL Programming

Michael McLaughlin
Oracle PL/SQL for DBAs

Oracle PL/SQL for DBAs

Arup Nanda, Steven Feuerstein
Oracle PL/SQL For Dummies

Oracle PL/SQL For Dummies

Michael Rosenblum, Paul Dorsey

Publisher Resources

ISBN: 9781449324070Supplemental ContentErrata Page