Examine the EMPLOYEES table structure:
Now, examine this code:
Which statement is true about the result of executing this block?
Examine the EMPLOYEES table structure:
Now, examine this code:
Which statement is true about the result of executing this block?
The given PL/SQL block will execute successfully provided that the salary of the EMP_ID 200 does not exceed the value 99999. The reason is that v_salary is declared as NUMBER(5), which can store a maximum value of 99999. Any value above this will result in an error when attempting to assign it to v_salary. Therefore, as long as the salary does not exceed 99999, the block will execute without errors.
Wouldn’t C be right once it doesn’t prefix the type with the table name?
ORA-06502: PL/SQL: numeric or value error: number precision too large. Therefore answer is A
I think A is correct
Seems like none of them is correct. Closest to the truth is A, but 99999.01 is greater than 99999 and still makes the program work... so as long as the rounded number does not exceed 6 digits it will work without an error.
select salary, first_name from employees where employee_id = 200; --salary = 5400 update employees set salary = salary + 0.58 where employee_id = 200; commit; select salary, first_name from employees where employee_id = 200; --salary = 5400.58 declare first_name employees.first_name%type; v_name first_name%type; v_salary number(5); v_emp_id employees.employee_id%type := 200; begin select salary, first_name into v_salary, first_name from employees where employee_id = v_emp_id; dbms_output.put_line('v_salary is '||v_salary ||' first_name is '||first_name); end; --v_salary is 5401 first_name is George E is correct
No, you are incorrect. As you have showed in your example when the anonymous block is executed the number 5400.58 is rounded to 5401, so if the salary of employee 200 is bigger that 99999.49(for example 99999.50. The block will try to round the salary to 100000) that will get the error: ORA-06502: PL/SQL: numeric or value error: number precision too large and so the correct answer is A