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
How do I save the results of sql query in a file?
How do you clear the screen in sql?
Explain table and field in sql?
What is scope of pl sql developer in future?
What is orm in sql?
what is the difference between delete and truncate statement in sql? : Sql dba
How do I find duplicates in the same column?
Does pl sql work in mysql?
Can there be 2 primary keys in a table?
How do I remove duplicates in two columns?
Is sqlite free?
what is the difference between a web-garden and a web-farm? : Sql dba
Does sql between include endpoints?
can a stored procedure call itself or recursive stored procedure? : Sql dba
How to run sql functions in pl/sql?