Home » SQL & PL/SQL » SQL & PL/SQL » Row not found
Row not found [message #278066] Thu, 01 November 2007 12:50 Go to next message
toshidas2000
Messages: 120
Registered: November 2005
Senior Member
All
In a procedure, I am putting following

select * into C1
from userid
where fname=v_fname
and lname=v_lname

This is not a cursor, How do I put a condition where C1 doesnot have a record.???

IF C1%NOTFOUND then

this does not work, Please help..
Re: Row not found [message #278067 is a reply to message #278066] Thu, 01 November 2007 12:52 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
Show us the context in which you use this query.
(and please use the correct forum, this is not an expert question)
Re: Row not found [message #278068 is a reply to message #278066] Thu, 01 November 2007 12:53 Go to previous messageGo to next message
toshidas2000
Messages: 120
Registered: November 2005
Senior Member
I am looking when the query does not return a row, how do I check that condition??
Re: Row not found [message #278070 is a reply to message #278066] Thu, 01 November 2007 13:08 Go to previous messageGo to next message
MarcL
Messages: 455
Registered: November 2006
Location: Connecticut, USA
Senior Member
Try looking up Exception and when_no_data_found.
Re: Row not found [message #278071 is a reply to message #278066] Thu, 01 November 2007 13:14 Go to previous messageGo to next message
Michel Cadot
Messages: 64151
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
SQL%NOTFOUND

Regards
Michel
Re: Row not found [message #278074 is a reply to message #278071] Thu, 01 November 2007 13:37 Go to previous messageGo to next message
MarcL
Messages: 455
Registered: November 2006
Location: Connecticut, USA
Senior Member
Michel Cadot wrote on Thu, 01 November 2007 13:14

SQL%NOTFOUND





How does that prevent the no data found exception? Am I missing something ?
Re: Row not found [message #278077 is a reply to message #278074] Thu, 01 November 2007 14:06 Go to previous messageGo to next message
Michel Cadot
Messages: 64151
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
It does not prevent from the exception but help to test afterwards.
It was not a replacement to your anwer just a complement:
SQL> create table t (col integer);

Table created.

SQL> declare 
  2    i pls_integer;
  3  begin
  4    begin
  5      select col into i from t;
  6    exception when no_data_found then null;
  7    end;
  8    if SQL%NOTFOUND then
  9      dbms_output.put_line('No row');
 10    end if;
 11  end;
 12  /
No row

PL/SQL procedure successfully completed.

Regards
Michel
Re: Row not found [message #278079 is a reply to message #278066] Thu, 01 November 2007 14:11 Go to previous messageGo to next message
MarcL
Messages: 455
Registered: November 2006
Location: Connecticut, USA
Senior Member
It must be time to start drinking :}

Re: Row not found [message #278087 is a reply to message #278079] Thu, 01 November 2007 14:29 Go to previous message
Littlefoot
Messages: 20901
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
You mean to stop drinking, right? ./fa/1602/0/

[Updated on: Thu, 01 November 2007 14:30]

Report message to a moderator

Previous Topic: Order By help needed
Next Topic: Comparing two strings
Goto Forum:
  


Current Time: Fri Dec 09 15:24:27 CST 2016

Total time taken to generate the page: 0.11501 seconds