Mega Code Archive

 
Categories / Oracle PLSQL Tutorial / PL SQL Data Types
 

Testing for equality of records

SQL> DECLARE   2    TYPE hrc_company_rec IS RECORD   3      (hrc_company_id NUMBER,   4       product_description VARCHAR2(20),   5       company_short_name VARCHAR2(30));   6    v_example_rec1 hrc_company_rec;   7    v_example_rec2 hrc_company_rec;   8  BEGIN   9    v_example_rec1.hrc_company_id :=1001;  10  11    v_example_rec1.product_description :='CEO/COO';  12  13    v_example_rec1.company_short_name :='O Inc.';  14  15    v_example_rec2.hrc_company_id :=1002;  16  17    v_example_rec2.product_description :='VP ';  18  19    v_example_rec2.company_short_name :='Office Inc.';  20  21    IF ((v_example_rec1.hrc_company_id =v_example_rec2.hrc_company_id) AND  22       (v_example_rec1.product_description =v_example_rec2.product_description) AND  23       (v_example_rec1.company_short_name =v_example_rec2.company_short_name)) THEN  24      dbms_output.put_line('Both example records are identical.');  25    ELSE  26      dbms_output.put_line('The two example records are different.');  27    END IF;  28  END;  29  / The two example records are different. PL/SQL procedure successfully completed. SQL>