Home » SQL & PL/SQL » SQL & PL/SQL » getting error ora-01403 data not found when i execute a simple select statement
getting error ora-01403 data not found when i execute a simple select statement [message #18917] Thu, 21 February 2002 03:33 Go to next message
ksr
Messages: 112
Registered: January 2002
Senior Member
Hi,
when i execute the below code,i get the error as ora-01403,data not found.How to overcome this.
Actually there is no matching record,just i want to check,if any record is there then it should return me the idcity else it should not do anything(just printing nothing)

declare
city1 number;
begin
select idcity into city1 from city where
upper(dsnmcity) = upper('city11') ;
if sql%found then
dbms_output.put_line(city1);
else
dbms_output.put_line('not');
end if;
end;
Re: getting error ora-01403 data not found when i execute a simple select statement [message #18921 is a reply to message #18917] Thu, 21 February 2002 05:39 Go to previous messageGo to next message
Suresh Vemulapalli
Messages: 624
Registered: August 2000
Senior Member
declare
city1 number;
begin
select idcity into city1 from city where
upper(dsnmcity) = upper('city11') ;

dbms_output.put_line(city1);
exception
when no_data_found then
dbms_output.put_line('not');
end;
Re: getting error ora-01403 data not found when i execute a simple select statement [message #18923 is a reply to message #18917] Thu, 21 February 2002 05:58 Go to previous messageGo to next message
INTROV
Messages: 20
Registered: February 2002
Junior Member
If a SELECT INTO statement fails to return a row, PL/SQL raises the predefined
exception NO_DATA_FOUND whether you check %NOTFOUND on the next line or not.

Write an exception handler

EXCEPTION
WHEN NO_DATA_FOUND THEN ...
Re: getting error ora-01403 data not found when i execute a simple select statement [message #18929 is a reply to message #18923] Thu, 21 February 2002 08:10 Go to previous message
ksr
Messages: 112
Registered: January 2002
Senior Member
hi,
is it not that i can give an if condition.
like
this select statement fails,
i give select * from tab where col1 = 123;

if sql%found then
do something...
else
do something..

If i want to achieve such a thing,what should be the statement framed and what is the work around.
Previous Topic: Adding a sequence number to a table. what should be the datatype of that column?
Next Topic: create sql to add indexes to all foreign keys
Goto Forum:
  


Current Time: Fri Sep 24 05:04:01 CDT 2021