x
login about faq Site discussion (meta-askssc)

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 '11 at 07:06 PM in Default

sqlnewb gravatar image

sqlnewb
216 10 27 31

(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



Facebook logo Follow Ask SSC on Facebook
Find Ask SSC on Google+
linkedin logo Find us on LinkedIn

Topics:

x359
x340
x6

asked: Oct 10 '11 at 07:06 PM

Seen: 323 times

Last Updated: Oct 10 '11 at 11:47 PM

Copyright © 2002-2012 Simple Talk Publishing. All Rights Reserved. If you have any queries, please contact the site administrators.
Ask SQL Server Central is a community service provided by Red Gate.