What output will come in following program? DECLARE
TYPE EmpRec IS RECORD (last_name employees.last_name%TYPE, salary employees.salary%TYPE);
emp_info EmpRec;
emp_id NUMBER := 100;
BEGIN
UPDATE employees SET salary = salary * 1.1 WHERE employee_id = emp_id
RETURNING last_name, salary INTO emp_info;
dbms_output.put_line('Just gave a raise to ' || emp_info.last_name ||
', who now makes ' || emp_info.salary);
ROLLBACK;
END;

Options
- Record is inserted into employees table.
- Executes and updates the salary of an employee.
- Compilation Error
- None of the Above


CORRECT ANSWER : Executes and updates the salary of an employee.

Discussion Board
Rollback is there

Rollback statement will rollback the changes made by the update (DML) statement. BT the program will execute successfully. So, "D" should be the answer

Karthikeyan 09-5-2016 07:56 AM

wrong Answer for the Question it should be None of the above.

Detail of the execution--->
SQL> select * from emp where employee_id=100;

EMPLOYEE_ID FIRST_NAME LAST_NAME
----------- -------------------- -------------------------
EMAIL PHONE_NUMBER HIRE_DATE JOB_ID SALARY
------------------------- -------------------- --------- ---------- ----------
COMMISSION_PCT MANAGER_ID DEPARTMENT_ID
-------------- ---------- -------------
100 Steven King
SKING 515.123.4567 17-JUN-03 AD_PRES 24000
90

SQL> declare
2 type emprec is record (empName emp.last_name%type,
3 empSalary emp.salary%type);
4 emp_info emprec;
5 BEGIN
6 UPDATE emp
7 SET Salary = Salary *1.1
8 WHERE employee_id = 100
9 RETURNING lasT_name, Salary
10 INTO emp_info;
11
12 DBMS_OUTPUT.put_line('Name of Employee: ' || emp_info.empName );
13 DBMS_OUTPUT.put_line('New Salary: ' || emp_info.empSalary);
14 Rollback;
15 end;
16 /
Name of Employee: King
New Salary: 26400

PL/SQL procedure successfully completed.

SQL> select * from emp where employee_id=100;

EMPLOYEE_ID FIRST_NAME LAST_NAME
----------- -------------------- -------------------------
EMAIL PHONE_NUMBER HIRE_DATE JOB_ID SALARY
------------------------- -------------------- --------- ---------- ----------
COMMISSION_PCT MANAGER_ID DEPARTMENT_ID
-------------- ---------- -------------
100 Steven King
SKING 515.123.4567 17-JUN-03 AD_PRES 24000
90


SQL>

harish 03-13-2015 07:55 AM

Write your comments


Enter the code shown above:

(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)


Advertisement