What is the outcome?

View Exhibit1 and examine the structure of the EMP table.


View Exhibit2 and examine the PIVSQL block of code.


What is the outcome?
A. It gives an error because the return type is not valid.
B. It gives an error because the record type is not defined within the function
C. It gives an error because the function call in DBMS_OUTPUT. PUT__LINE is not valid
D. It executes successfully and displays the names and salaries of all employees who earn the highest salary.
E. It executes successfully but does not display the names and salaries of all employees who earn the highest salary.

Download Printable PDF. VALID exam to help you PASS.

2 thoughts on “What is the outcome?

  1. Agree with MDA, correct answer is E.
    It happens because RETURN exits both loop and function in first iteration.
    So only one of employees with highest salary is returned.

  2. E is correct.

    create table emp(emp_id Number(6) primary key, ename Varchar(30), sal Number(8,2));
    Insert Into emp Values (100, ‘Daniel’, 19000) ;
    Insert Into emp Values (300, ‘Laura’, 19000) ;
    Insert Into emp Values (500, ‘Shanta’, 15000) ;
    commit;

    declare
    type EmpREcTyp is record (
    ename varchar2(30)
    , sal number(8,2)
    );
    FUNCTION highest_salary RETURN EmpREcTyp IS
    emp_info EmpREcTyp;
    CURSOR cur_emp_cursor IS
    select ename, sal
    from emp where sal = (select max(sal) from emp)
    ;
    BEGIN
    for emp_info in cur_emp_cursor
    LOOP
    RETURN emp_info;
    END LOOP;
    END highest_salary;
    BEGIN
    DBMS_OUTPUT.PUT_LINE(‘Emp : ‘||highest_salary().ename||
    ‘ earns the highest salary of ‘||highest_salary().sal
    );
    END;
    /

    2
    1

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.