Dear All,



Question for this Week



Find out possible error(s) (either at compile
time or at runtime) in the following PL/SQL block. State
the reason(s) and correct the errors.



Declare

Cursor C1 is select ename, sal, comm from emp;

Begin

For i in C1 Loop

If i.comm between 299 and 999 then

Dbms_output.put_line(i.Ename || ‘
** Good Commission’);

Elsif i.comm > 999 then

Dbms_output.put_line(i.Empno || ‘
** Very Good Commission’);

close C1;

Else

Dbms_output.put_line(i.Ename || ‘
** ’ ||nvl(i.comm,‘O’));

End if;

End Loop;

End;

Answer Posted / tanmay agrawal

DECLARE
CURSOR C1
IS
SELECT empno,ename, sal, comm FROM emp;
BEGIN
FOR i IN C1
LOOP
IF i.comm BETWEEN 299 AND 999 THEN
Dbms_output.put_line(i.Ename || ' ** Good Commission');
elsif i.comm > 999 THEN
Dbms_output.put_line(i.Empno || ' ** Very Good Commission');
-- CLOSE C1;
ELSE
Dbms_output.put_line(i.Ename || ' ** ' ||NVL(to_char(i.comm),'O'));
END IF;
END LOOP;
END;

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why do we use view in sql?

524


what is the difference between ereg_replace() and eregi_replace()? : Sql dba

540


How to fetch values from testtable1 that are not in testtable2 without using not keyword?

739


What is use of trigger?

505


What does over partition by mean in sql?

519






What are all the ddl commands?

614


How long it takes to learn pl sql?

523


What is optimistic concurrency control? : Transact sql

536


what is column? : Sql dba

560


what happens if null values are involved in expressions? : Sql dba

557


What are the subsets of sql?

541


how to create a test table in your mysql server? : Sql dba

483


What is the process of copying data from table a to table b?

587


Why use subqueries instead of joins?

592


Explain the uses of control file.

605