x

Catching Exceptions

How would I go about catching this error before it got to the when others clause? I KNOW I NEED TO WRAP THE INNER BLOCK WITH A BEGIN AND END BUT I THINK I AM PUTTIN ONE OF THE BEGIN IN THE WRONG PLACE

Using oracle

 CREATE OR REPLACE PROCEDURE example1 
 
 (
   p_first_name IN varchar2)
 
 as
     v_test_variable varchar(4) := p_first_name;
 BEGIN
  BEGIN
   DBMS_OUTPUT.PUT_LINE('Exception Propagation Example 1');
  EXCEPTION
  when others then
   DBMS_OUTPUT.PUT_LINE('An error occured in the declaration section ');
 END ;
 
 
 EXCEPTION
     WHEN value_error THEN
     DBMS_OUTPUT.PUT_LINE('You cant put ['||V_TEST_VARIABLE || '] in a 4 character string.');
 END example1;
 /
 show errors
     EXEC EXAMPLE1('hello')
more ▼

asked Oct 10, 2011 at 07:06 PM in Default

avatar image

sqlnewb
216 29 32 35

(comments are locked)
10|1200 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.

Topics:

x455
x425
x9

asked: Oct 10, 2011 at 07:06 PM

Seen: 756 times

Last Updated: Oct 10, 2011 at 11:47 PM

Copyright 2016 Redgate Software. Privacy Policy