RSS

7.7.1 USE the EXCEPTION_INIT Pragma

23 Apr

SET SERVEROUTPUT ON

DECLARE

    e_constraint_violation EXCEPTION;

    PRAGMA EXCEPTION_INIT(e_constraint_violation, 1400);

BEGIN

    INSERT INTO course (course_no, description, created_by,     created_date)

        VALUES (COURSE_NO_SEQ.NEXTVAL, ‘TEST COURSE’, USER, SYSDATE);

    COMMIT;

    DBMS_OUTPUT.PUT_LINE (‘One course has been added’);

EXCEPTION

    WHEN e_constraint_violation THEN

        DBMS_OUTPUT.PUT_LINE (‘INSERT statement is ‘||‘violating a constraint’);

END;

Advertisements
 
Leave a comment

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