SIMPLE QUESTION [message #3382] |
Tue, 24 September 2002 09:42 |
HIT1
Messages: 4 Registered: September 2002
|
Junior Member |
|
|
in pl/sql block if i write one query
as
declare
begin
select * from emp where empno=9999;
if sql%notfound then
dbms_output.put_line('error message in sql cursor');
end if;
exception when no_data_found then
dbms_output.put_line('error message in exception');
end exception;
end;
may be syntax was somewhat wrong but question is like this.
what will be output????
|
|
|
Re: SIMPLE QUESTION [message #3384 is a reply to message #3382] |
Tue, 24 September 2002 10:07 |
Todd Barry
Messages: 4819 Registered: August 2001
|
Senior Member |
|
|
In PL/SQL, you must always select INTO a variable. Also, a SQL%NOTFOUND statement is not relevent with a SELECT INTO. If a single row is not returned, either a NO_DATA_FOUND or a TOO_MANY_ROWS exception will be raised.
declare
v_empno emp.empno%type;
begin
select empno
into v_empno
from emp
where empno = 9999;
exception
when no_data_found then
dbms_output.put_line(...);
end;
|
|
|