RSS

7.5.2 Reraise Exceptions

19 Apr

SET SERVEROUTPUT ON;

DECLARE

    v_course_no NUMBER := 430;

    v_total NUMBER;

    e_no_sections   EXCEPTION;

BEGIN

    BEGIN

        SELECT COUNT(*)

            INTO v_total

            FROM SECTION

            WHERE course_no = v_course_no;

        IF v_total = 0 THEN

            RAISE e_no_sections;

        ELSE

            DBMS_OUTPUT.PUT_LINE(‘Course, ‘ || v_course_no || ‘ has ‘ || v_total || ‘ sections’);

        END IF;

    EXCEPTION

        WHEN e_no_sections THEN

            DBMS_OUTPUT.PUT_LINE(‘There are no sections for course ‘ || v_course_no);

    END;

    DBMS_OUTPUT.PUT_LINE(‘Done…’);

END;

 

 

 

SET SERVEROUTPUT ON;

DECLARE

    v_course_no NUMBER := 430;

    v_total NUMBER;

    e_no_sections   EXCEPTION;

BEGIN

    BEGIN

        SELECT COUNT(*)

            INTO v_total

            FROM SECTION

            WHERE course_no = v_course_no;

        IF v_total = 0 THEN

            RAISE e_no_sections;

        ELSE

            DBMS_OUTPUT.PUT_LINE(‘Course, ‘ || v_course_no || ‘ has ‘ || v_total || ‘ sections’);

        END IF;

    EXCEPTION

        WHEN e_no_sections THEN

            RAISE;

    END;

    DBMS_OUTPUT.PUT_LINE(‘Done…’);

EXCEPTION

    WHEN e_no_sections THEN

        DBMS_OUTPUT.PUT_LINE(‘There are no sections for course ‘ || v_course_no);

END;

Advertisements
 
Leave a comment

Posted by on 04/19/2010 in ORACLE

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

 
%d bloggers like this: