1.

What does each PL/SQL subprogram consist of?

Answer»

With PL/SQL, you can easily pass a record as a subprogram parameter in the same way pass any other variable.

The following is an example:

DECLARE TYPE LAPTOP IS RECORD (brand varchar(50),   RAM  number,   SNO  number ); lp1 laptop; lp2 laptop; lp3 laptop; PROCEDURE myDevice(lpt laptop) IS BEGIN  -- Laptop record   dbms_output.put_line('Laptop Brand = '|| lpt.brand);   dbms_output.put_line('Laptop RAM = '|| lpt.RAM);   dbms_output.put_line('Laptop SNO = ' || lpt.SNO); END; 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;   myDevice(lp1);   myDevice(lp2);   myDevice(lp3); END; /

The output:

Laptop Brand = Dell Laptop RAM = 4 Laptop SNO = 87667 Laptop Brand = Lenevo Laptop RAM = 4 Laptop SNO = 47656 Laptop Brand = HP Laptop RAM = 8 Laptop SNO = 98989


Discussion

No Comment Found