Home > SQL, Technical > Basic Exception Handling in PL/SQL

Basic Exception Handling in PL/SQL

Syntax:
======
DECLARE
………Declare statements
BEGIN
…………….
EXCEPTION
WHEN exception THEN
………actions
END;


Example:

======
SET SERVEROUTPUT ON
DECLARE
      OutputStr VARCHAR2(50);
BEGIN
      SELECT
            emp_no|| chr(2) || emp_salary
      INTO
            OutputStr
      FROM
            employee
      WHERE
            emp_name=”karuvatchi”;
EXCEPTION
      WHEN NO_DATA_FOUND THEN
            DBMS_OUTPUT.PUT_LINE(‘No Data Found Error occured’);
END;

Advertisements
Categories: SQL, Technical
  1. No comments yet.
  1. No trackbacks yet.

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: