FUNCTION COMPARE_RECORDS() DEFINE n1, n2 om.DomNode DEFINE child_node1, child_node2 om.DomNode DEFINE name1, name2 STRING DEFINE value1, value2 STRING DEFINE i, i_max INTEGER DEFINE r1, r2 RECORD key INTEGER, firstname CHAR(20), lastname CHAR(20), birthdate DATE END RECORD LET r1.key = 123 LET r1.firstname = "Grace" LET r1.lastname = "Hopper" LET r1.birthdate = "12/9/2006" LET n1 = base.TypeInfo.create(r1) LET r2.key = 123 LET r2.firstname = "Grace" LET r2.lastname = "Hopper" LET r2.birthdate = "12/9/1906" LET n2 = base.TypeInfo.create(r2) DISPLAY "RECORD 1:\n", n1.toString() DISPLAY "RECORD 2:\n", n2.toString() LET i_max = n1.getChildCount() FOR i = 1 TO i_max LET child_node1 = n1.getChildByIndex(i) LET name1 = child_node1.getAttribute("name") LET value1 = child_node1.getAttribute("value") LET child_node2 = n2.getChildByIndex(i) LET name2 = child_node2.getAttribute("name") LET value2 = child_node2.getAttribute("value") IF value1 != value2 THEN DISPLAY "DIFFERENCE FOUND" DISPLAY " record 1: ", name1, " = '", value1, "'" DISPLAY " record 2: ", name2, " = '", value2, "'" END IF END FOREND FUNCTION
RECORD 1:<?xml version='1.0' encoding='windows-1252'?><Record> <Field type="INTEGER" value="123" name="key"/> <Field type="CHAR(20)" value="Grace" name="firstname"/> <Field type="CHAR(20)" value="Hopper" name="lastname"/> <Field type="DATE" value="12/09/2006" name="birthdate"/></Record>RECORD 2:<?xml version='1.0' encoding='windows-1252'?><Record> <Field type="INTEGER" value="123" name="key"/> <Field type="CHAR(20)" value="Grace" name="firstname"/> <Field type="CHAR(20)" value="Hopper" name="lastname"/> <Field type="DATE" value="12/09/1906" name="birthdate"/></Record>DIFFERENCE FOUND record 1: birthdate = '12/09/2006' record 2: birthdate = '12/09/1906'
let node1 = base.TypeInfo.create(old_record) let node2 = base.TypeInfo.create(new_record) let i_max = node1.getChildCount() for i = 1 to i_max let child_node1 = node1.getChildByIndex(i) let col_type = child_node1.getAttribute("type") let col_name = child_node1.getAttribute("name") let old_value = child_node1.getAttribute("value") let child_node2 = node2.getChildByIndex(i) let new_value = child_node2.getAttribute("value") if (old_value is null and new_value is not null) or (new_value is null and old_value is not null) or (new_value != old_value) then display "Values differ for field ", col_name end if end for