Multiple choice

DANNY is coding a When-New-Form-Instance trigger to populate a hierarchical tree item called Emp_Tree that should initially appear as shown in the exhibit. Mr. King, the president of the company, is the only employee who does not have a manager.

In the trigger, DANNY declares a variable called rg_emps that is of the RECORD GROUP data type. He will use this record group to populate the tree. He uses the following code to create the record group:

rg_emps := Create_Group_Form_Query('rg_emps', 'Select 1, level, last_name, NULL, to_char(employee_id) from employees connect by prior employee_id = manager_id; start with manager_id is null');

He then programmatically populates the record group, and then populates the tree with the record group. He runs the form to test it. Will the tree initially appear as shown? If not, why?

  1. Yes, the tree will appear as shown.

  2. No, the first element selected in the select statement should be 4 because he wanted four levels of the tree to be displayed.

  3. No, he should eliminate the last element selected in the select statement, because he does not want to display the employees ID.

  4. No, the 'connect by' statement should be 'connect by prior manager_id = employee_id'.

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

The hierarchical query syntax is correct: CONNECT BY PRIOR employee_id = manager_id builds the tree from parent to child, and START WITH manager_id IS NULL correctly identifies Mr. King as the root. The query structure (1, level, last_name, NULL, to_char(employee_id)) properly defines tree depth, label, and data attributes. Option D's suggestion to reverse PRIOR would produce incorrect hierarchy.