Use The Implicit cursor to Query The Department table information Where Deptno is 30.check,if no record was found then print "Record Was Not Found".Else Print Deptname And Ename.Dept table Have Dname Varchar2(20),Deptno Number,EnameVarchar2(20).Please Answer In 2 mins,with in Maximum 15 lines.
Answers were Sorted based on User's Feedback
Answer / vikas gupta
Declare
l_deptname dept.deptname%Type;
l_ename dept.ename%type;
Begin
select deptname,ename
into l_deptname,l_ename
from dept
where dept_no = 30;
if sql%notfound then
dbms_output.put_line("Record was not Found")
else
dbms_output.put_line("Deptname=" l_deptname);
dbms_output.put_line("Ename=" l_ename);
end if;
end;
| Is This Answer Correct ? | 10 Yes | 8 No |
Answer / debasis mohanty
If That dept 30 contains more than 1 employee then your answer is wrong
erorr:exact fetch returns more than 1 rows
| Is This Answer Correct ? | 3 Yes | 1 No |
Answer / swastik
declare
v_deptno number(2) := &gdeptno;
v_dname varchar2(20);
v_ename varchar2(20);
begin
select deptno, dname, ename into v_deptno, v_dname, v_ename
from dept
where deptno = v_deptno;
dbms_output.put_line(v_deptno|| ' '||v_dname||' '||v_ename);
exception
when no_data_found
then
dbms_output.put_line('record was not found');
end;
/
| Is This Answer Correct ? | 2 Yes | 0 No |
Answer / dmddebasismohanty183
Please Send Me The Answer
Thanks And Regards
Debasis Mohanty
dmdebasismohanty183@gmail.com
Contact:08722140827
| Is This Answer Correct ? | 0 Yes | 0 No |
declare
cursor mycursor is
select dname,ename from emp ,dept where emp.deptno=dept.deptno and dept.deptno=30;
v_dname dept.dname%type;
v_ename emp.ename%type;
begin
open mycursor;
loop
exit when mycursor%notfound;
fetch mycursor into v_dname,v_ename;
exception
when no_data_found then
dbms_output.put_line(v_dname||' '||v_ename);
end loop;
close mycursor;
end;
| Is This Answer Correct ? | 2 Yes | 6 No |
What is the difference between having and a where in sql?
Is it possible to create startup or shutdown trigger for on-schema?
What is a table in a database?
what is Complex index. how to create it?
Types of joins?
How do you know if a relationship is 2nf?
Can we debug stored procedure?
what is oracle database ? : Sql dba
What are the return values of functions SQLCODE and SQLERRM ?
How many sql are there?
How does one load ebcdic data? : aql loader
What are the basic techniques of indexing?
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)