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 is there a need for sqlcode and sqlerrm variables?

655


how to rename an existing table in mysql? : Sql dba

655


Can we rename a column in the output of sql query?

620


What is indexes?

646


Can we insert data into view?

600






how to dump a table to a file with 'mysqldump'? : Sql dba

638


How will you distinguish a global variable with a local variable in pl/sql?

711


What is the difference between pl and sql?

628


How many postgresql users are there, worldwide?

671


how can we transpose a table using sql (changing rows to column or vice-versa) ? : Sql dba

606


What are the disadvantages of not performing database normalization?

686


Explain the purpose of %type and %rowtype data types?

590


What are sql functions? Describe in brief different types of sql functions?

573


what is foreign key? : Sql dba

667


What is the difference between jpql and sql?

669