View the Exhibit to examine the PIVSQL block.
Which statement is true about the output of the PL/SQL block?
A.
It executes and the Output is emprec.deptname: .
B.
It executes and the Output is emprec.deptname: Sales.
C.
It produces an error because NULL is assigned to the emprec.empid field in the record.
D.
It produces anerror because the CHECK constraint is violated while assigning a value to the
emprec.deptid field in the record.
A
A
a
The variable emprec does dot inherits the constraints. The correct answer is A.
B is incorrect because DEFAULT is a constraint type.
http://www.w3schools.com/sql/sql_default.asp
A
create table employee_temp(
empid number(6) not null primary key,
deptid number(6) constraint c_employee_temp_dept check (deptId between 100 and 200),
deptname varchar2(30) default ‘Sales’);
declare
emprec employee_temp %rowtype;
begin
emprec.empid := null;
emprec.deptid := 50;
dbms_output.put_line(’emprec.deptname :’ || emprec.deptname);
end;
A
“The %ROWTYPE attribute provides a record type that represents a row in a table or view. Columns in a row and corresponding fields in a record have the same names and datatypes. However, fields in a %ROWTYPE record do not inherit constraints, such as the NOT NULL or check constraint, or default values.”
Source: https://docs.oracle.com/cd/B19306_01/appdev.102/b14261/fundamentals.htm
Correct Answer: A