InterviewSolution
Saved Bookmarks
| 1. |
When COLLECTION_IS_NULL exception raised in PL/SQL? |
|
Answer» The dot(.) operator is to be used in PL/SQL to access the fields of a record. This is between the record variable and the field. Let US take an example of a record. This is how you can DECLARE: DECLARE TYPE laptop IS RECORD (brand varchar(50), RAM number, SNO number, ); l1 laptop; l1 laptop;You can now access the fields using the dot(.) operator. The following is the example WHEREIN we have created user-define records and accesses the fields: DECLARE TYPE laptop IS RECORD (brand varchar(50), RAM number, SNO number ); lp1 laptop; lp2 laptop; lp3 laptop; BEGIN -- Laptop 1 specification lp1.brand:= 'Dell'; lp1.RAM:= 4; lp1.SNO:= 87667; -- Laptop 2 specification lp2.brand:= 'Lenevo'; lp2.RAM:= 4; lp2.SNO:= 47656; -- Laptop 3 specification lp3.brand:= 'HP'; lp3.RAM:= 8; lp3.SNO:= 98989; -- Laptop 1 record dbms_output.put_line('Laptop 1 Brand = '|| lp1.brand); dbms_output.put_line('Laptop 1 RAM = '|| lp1.RAM); dbms_output.put_line('Laptop 1 SNO = ' || lp1.SNO); -- Laptop 2 record dbms_output.put_line('Laptop 2 Brand = '|| lp2.brand); dbms_output.put_line('Laptop 2 RAM = '|| lp2.RAM); dbms_output.put_line('Laptop 2 SNO = ' || lp2.SNO); -- Laptop 3 record dbms_output.put_line('Laptop 3 Brand = '|| lp3.brand); dbms_output.put_line('Laptop 3 RAM = '|| lp3.RAM); dbms_output.put_line('Laptop 2 SNO = ' || lp3.SNO); END;The output: Laptop 1 Brand = Dell Laptop 1 RAM = 4 Laptop 1 SNO = 87667 Laptop 2 Brand = Lenevo Laptop 2 RAM = 4 Laptop 2 SNO = 47656 Laptop 3 Brand = HP Laptop 3 RAM = 8 Laptop 2 SNO = 98989 |
|