Home » SQL & PL/SQL » SQL & PL/SQL » About select into
About select into [message #36945] Mon, 07 January 2002 03:14 Go to next message
orafan
Messages: 8
Registered: December 2001
Junior Member
When using SELECT INTO statement in PL/SQL, NO_DATA_FOUND exception will be raised if query returns no row.
To handle this error, we have two ways:
1. handle it in the EXCEPTION part of the procedure
2. use SELECT COUNT(*) to determin if query will return no row or not first, then use SELECT INTO statement.
Which one is better( I prefer the first one)?
Is there any other method to handle this error?
Re: About select into [message #36946 is a reply to message #36945] Mon, 07 January 2002 03:55 Go to previous messageGo to next message
Satish Shrikhande
Messages: 167
Registered: October 2001
Senior Member
I use the first method , i think it's the best .
Re: About select into [message #36960 is a reply to message #36945] Mon, 07 January 2002 10:40 Go to previous messageGo to next message
raghav banuru
Messages: 6
Registered: January 2002
Junior Member
I think you are correct the first solution is the best solution

All the Best
Re: About select into [message #36994 is a reply to message #36945] Wed, 09 January 2002 11:13 Go to previous messageGo to next message
Srinivas Konda
Messages: 29
Registered: October 2001
Junior Member
Transform your SELECT statement into a cursor, CURSORs never raise a NO_DATA_FOUND EXCEPTION.

You can use your 1st. method but Writing a cursor is a good practice than a select statement.
Re: About select into [message #38189 is a reply to message #36994] Fri, 29 March 2002 08:52 Go to previous message
Ellen
Messages: 5
Registered: April 2000
Junior Member
select * into existing_tables from old_tables where id = 'adfd'

it did not work because it said "existing_tables" is already in the database.

Is there anyway can overwritten it?

Thanks
Previous Topic: range scan
Next Topic: Unable to start SQL*LOADER session
Goto Forum:
  


Current Time: Thu Apr 25 06:39:35 CDT 2024