RSS

7.6.1 Use RAISE_APPLICATION_ERROR

21 Apr

SET SERVEROUTPUT ON

DECLARE

    v_students NUMBER(3) := 0;

BEGIN

    SELECT COUNT(*)

        INTO v_students

        FROM enrollment e, section s

        WHERE e.section_id = s.section_id

            AND s.course_no = 25

            AND s.section_id = 89;

    IF v_students > 10 THEN

        RAISE_APPLICATION_ERROR(-20002, ‘Course 25, section 89 has more than 10 students’);

    END IF;

    DBMS_OUTPUT.PUT_LINE (‘Course 25, section 89 has ‘||v_students||    ‘ students’);

END;

Advertisements
 
Leave a comment

Posted by on 04/21/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: