Oracle Database: Program with PL/SQL — Question 73
Which two blocks of code execute successfully?
Answer options
- A. DECLARE SUBTYPE new_one IS BINARY_INTERGER RANGE 0..9; my_val new_one; BEGIN my_val :=0; END;
- B. DECLARE SUBTYPE new_string IS VARCHAR2 (5) NOT NULL; my_str_new_string; BEGIN my_str := abc; END;
- C. DECLARE SUBTYPE new_one IS NUMBER (2, 1); my_val new_one; BEGIN my_val :=12.5; END;
- D. DECLARE SUBTYPE new_one IS INTEGER RANGE 1..10 NOT NULL; my_val new_one; BEGIN my_val :=2; END;
- E. DECLARE SUBTYPE new_one IS NUMBER (1, 0); my_val new_one; BEGIN my_val := -1;
Correct answer: A, D
Explanation
Options A and D execute successfully because they declare valid subtypes and assign values within the specified ranges. Option B fails because 'my_str' is not defined correctly, C is invalid as it assigns a value that exceeds the defined precision, and E fails due to trying to assign a negative value to a subtype that allows only positive integers.