I have a small PL/SQL Block
assume in this way
begin
select * from emp where empno=100;
exception
when others then
<Some Messages>
when no_data_found then
<Some Messages>
when too_many_rows then
<Some Messages>
end;
The question which he asked was whether this block will get
executed normally or it will throw error ?
If errored out then what is the reason for the error ?
Could anybody please help me ?
Regards
Nakul Venkataraman
Answers were Sorted based on User's Feedback
Answer / kavitha nedigunta
yes this will give error,
1.need to include the into clause.
(PLS-00428: an INTO clause is expected in this SELECT
statement)
2.as in exception block when others
should be at the bottom of the exception block.
(PLS-00370: OTHERS handler must be last among the exception
handlers of a block)
| Is This Answer Correct ? | 20 Yes | 0 No |
Answer / virendra
yes this will give error, as in exception block when others
should be at the bottom of the exception block.
ex.
exception
when no_data_found then
<Some Messages>
when too_many_rows then
<Some Messages>
when others then
<Some Messages>
end;
| Is This Answer Correct ? | 19 Yes | 3 No |
Answer / sdp
Yes , it will give an error as for single row queries we
need to include the into clause also
the query would be
declare
v_emp emp%rowtype%;
begin
select * into v_emp from emp where empno=100;
exception
---
---
end;
| Is This Answer Correct ? | 5 Yes | 8 No |
In a PL/SQL block,which loop type should be used in a performance point of view & Why (as both loops can do the same task) 1) open - Fetch loop 2) for loop
What is cursor status?
Why is a primary key important?
Does access use sql?
What will you get by the cursor attribute sql%rowcount?
What does rownum mean in sql?
Write a query to display the current date in sql?
What is an exception in pl/sql?
Explain how to use transactions efficiently : transact sql
Is primary key an index?
what is not null constraint? : Sql dba
What is the syntax to add a record to a table?
Oracle (3259)
SQL Server (4518)
MS Access (429)
MySQL (1402)
Postgre (483)
Sybase (267)
DB Architecture (141)
DB Administration (291)
DB Development (113)
SQL PLSQL (3330)
MongoDB (502)
IBM Informix (50)
Neo4j (82)
InfluxDB (0)
Apache CouchDB (44)
Firebird (5)
Database Management (1411)
Databases AllOther (288)