0% found this document useful (0 votes)
20 views

PLSQL

This PL/SQL block declares variables, performs a SQL query to select an employee name into a variable based on an ID, checks if data is found, and raises an exception if not found while outputting an error message.

Uploaded by

Ruturaj Ghodake
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

PLSQL

This PL/SQL block declares variables, performs a SQL query to select an employee name into a variable based on an ID, checks if data is found, and raises an exception if not found while outputting an error message.

Uploaded by

Ruturaj Ghodake
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

declare

no_value EXCEPTION;
v_id number(10):=&v_id;
v_name varchar2(10);
begin
select emp_name into v_name from employees where emp_id=v_id;
if sql%found then
dbms_output.put_line('name of employees --> '||v_name);
end if;
if sql%notfound then
RAISE no_value;
end if;
exception
when no_value then
dbms_output.put_line('no such data');
end;
/

You might also like