Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 6: Bulk SQL Operations > Error Handling with Bulk Bind

Error Handling with Bulk Bind

There are large benefits to had from bulk binding. But one area where extra care is required is in error handling. In a development model where rows are modified on a row-at-a-time basis, when a SQL statement fails with an error, the erroneous row in question is implicit—it’s the row you are working with. For example, in the following simple PL/SQL block (bulk_error_1.sql) with two insert statements, it is obvious which insert statement is the problem one:

SQL> alter table hardware
  2    add constraint
  3    hardware_chk check ( item > 0 );

Table altered.

SQL> begin
  2    insert into hardware ( item )  values (1);
  3    insert into hardware ( item ) values (-1);
  4    insert into hardware ( item ) values (2);
  5    insert into hardware ( item ) values (3);
  6    insert into hardware ( item ) values (4);
  7    insert into hardware ( item ) values (-2);
  8  end;
  9  /
begin
*
ERROR at line 1:
ORA-02290: check constraint (MCDONAC.HARDWARE_CHK) violated
ORA-06512: at line 3

  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial