Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

USING SQL oraclive live hr.employees Modify this code to output First name and L

ID: 3715798 • Letter: U

Question

USING SQL

oraclive live hr.employees

Modify this code to output First name and Last name

/* a REF curor is a SQL datatype value is a memory address

of a database table. It's a pointer or handle to a set result of a

database */

/* delcare cursor */

/* name of cursor is ref_cursor */

/* declare */

declare type ref_cursor is REF CURSOR;

var_emp ref_cursor;

/* create a workfield like lastname */

WLAST_NAME hr.employees.LAST_NAME%type;

begin

/*open*/

open var_emp for select LAST_NAME from HR.EMPLOYEES;

loop

        /*fetch*/

        fetch var_emp into WLAST_NAME;

        /* manipulate data with something.... */

        /* print out the info */

        dbms_output.put_line(WLAST_NAME);

         /* end manpluation */

        exit when var_emp%notfound;

end loop;

/*close */

close var_emp;

end;

Explanation / Answer

Dear Student,

This is executed on my machine.

declare
type ref_cursor is REF CURSOR;  
var_emp ref_cursor;  
varr hr.employees%rowtype;
begin  
open var_emp for select * from hr.employees;  
loop  
fetch var_emp into varr;  

exit when var_emp%notfound;  
dbms_output.put_line(varr.first_name||' '||varr.last_name);  
end loop;
close var_emp;
end;

Try modify the code as per your requirements.

Please like this if you got it. Thanks!