InterviewSolution
Saved Bookmarks
| 1. |
What are the guidelines to be used before creating a PL/SQL Package? |
|
Answer» VARRARY data STRUCTURE store a fixed-size sequential collection of elements of the same type. It has contiguous memory locations with the lowest address as the FIRST element and the highest address as the last element. The CREATE TYPE statement is used to create a varray type. The following is the syntax for creating a VARRAY type within a PL/SQL block: TYPE name_of_varray_type IS VARRAY(n) of <type_of_element>Here, n is the number of elements, name_of_varray_type is a valid attribute name, and type_of_element is the data type of the elements of the arrayThe following is an example: Type marks IS VARRAY(10) OF INTEGER;Let us see an example wherein we are DISPLAYING the appraisal points for employees according to their IDs: DECLARE type points IS VARRAY(10) OF INTEGER; appraisal_points points; total integer; BEGIN appraisal_points:= points(76, 79, 89, 96, 99, 86, 89, 97); total := appraisal_points.count; FOR i in 1 .. total LOOP dbms_output.put_line('Appraisal Points for Employee ' || i || ' = ' || appraisal_points(i)); END LOOP; END; /The output: Appraisal Points for Employee 1 = 76 Appraisal Points for Employee 2 = 79 Appraisal Points for Employee 3 = 89 Appraisal Points for Employee 4 = 96 Appraisal Points for Employee 5 = 99 Appraisal Points for Employee 6 = 86 Appraisal Points for Employee 7 = 89 Appraisal Points for Employee 8 = 97 |
|