Example: adding rows to a RowList
In this example, we create a MemRowList, then add two members with MemName and MemAttr segments to each member.
// Create a member row list.
MemRowList memberRows = new MemRowList();
// Create a MemHead object.
// MemHead models the
// database table mpi_memhead.
MemHead memHead = new MemHead();
// Set identifier data - srcCode/memIdnum
memHead.setSrcCode("RMC");
memHead.setMemIdnum("1002423");
// Set attributes for the member.
MemAttr memAttr = new MemAttr();
memAttr.setMemRecno(memHead.getMemRecno());
memAttr.setEntRecno(memHead.getEntRecno());
memAttr.setMemSeqno(memHead.generateNextMemSeqno());
// Set the segment attribute code(Listed in mpi_segattr table)
memAttr.setAttrCode("RACE");
memAttr.setAttrVal("01");
memAttr.setRowInd(RowInd.INSERT);
//As an alternate to the above method you can use IDS methods
//on the Row Object to also create a MemAttr and set values to it.
MemRow maIds = new MemRow("MemAttr");
try {
//init row with MemRecno/EntRecno of memHead
maIds.init(memHead);
maIds.setString("AttrCode", "SEX");
maIds.setString("AttrVal", "M");
maIds.setEnumRowInd("RowInd", RowInd.INSERT);
}
catch (SetterException e) {
System.err.println(e.get_Message());
}
// Set the name of the member
MemName memName = new MemName(memHead);
// Set the segment attribute code
memName.setAttrCode("LGLNAME");
memName.setOnmFirst("Rick");
memName.setOnmLast("Jones");
memName.setRowInd(RowInd.INSERT);
// Add this member information to the member row list
memberRows.addRow(memHead);
memberRows.addRow(memAttr);
memberRows.addRow(maIds);
memberRows.addRow(memName);
// Create another MemHead object
MemHead memHead1 = new MemHead();
// Set identifier data of second member – srcCode/memIdnum
memHead1.setSrcCode("RMC");
memHead1.setMemIdnum("1002424");
// Set attributes for the second member
MemAttr memAttr1 = new MemAttr();
memAttr1.setMemRecno(memHead.getMemRecno());
memAttr1.setEntRecno(memHead.getEntRecno());
memAttr1.setMemSeqno(memHead.generateNextMemSeqno());
memAttr1.setAttrCode("SEX");
memAttr1.setAttrVal("F");
memAttr1.setRowInd(RowInd.INSERT);
// Set the name of the second member.
MemName memName1 = new MemName(memHead1);
// Set the segment attribute code.
memName1.setAttrCode("LGLNAME");
memName1.setOnmFirst("Shane");
memName1.setOnmLast("Kau Lee");
memName1.setRowInd(RowInd.INSERT);
// Add the second member information to the row list.
memberRows.addRow(memHead1);
memberRows.addRow(memAttr1);
memberRows.addRow(memName1);
A memory dump of the RowList looks like:
** Mem Dump:
class madison.mpi.MemHead rowInd: A memRecno: -294967294 entRecno:
-294967294 memSeqno: 2 srcRecno: 0 srcCode: RMC memIdnum: 1002423
matchScore: 0 memStat: A srcFtime: Mon Dec 22 19:58:09 GMT+05:30 2003
srcLtime: Mon Dec 22 19:58:09 GMT+05:30 2003 recCtime: Mon Dec 22 19:58:09
GMT+05:30 2003 recMtime: Mon Dec 22 19:58:09 GMT+05:30 2003
class madison.mpi.MemAttr rowInd: A memRecno: -294967294 entRecno:
-294967294 memSeqno: 1 attrRecno: 0 asaIdxno: 0 attrCode: RACE attrName:
recStat: A srcFtime: Mon Dec 22 19:58:09 GMT+05:30 2003 srcLtime: Mon Dec 22
19:58:09 GMT+05:30 2003 recCtime: Mon Dec 22 19:58:09 GMT+05:30 2003
recMtime: Mon Dec 22 19:58:09 GMT+05:30 2003 attrVal: 01
class madison.mpi.MemName rowInd: A memRecno: -294967294 entRecno:
-294967294 memSeqno: 2 attrRecno: 0 asaIdxno: 0 attrCode: LGLNAME attrName:
recStat: A srcFtime: Mon Dec 22 19:58:09 GMT+05:30 2003 srcLtime: Mon Dec 22
19:58:09 GMT+05:30 2003 recCtime: Mon Dec 22 19:58:09 GMT+05:30 2003
recMtime: Mon Dec 22 19:58:09 GMT+05:30 2003 onmFirst: Rick onmMiddle:
onmLast: Jones onmPrefix: onmSuffix: onmDegree: onmTitle:
class madison.mpi.MemHead rowInd: A memRecno: -294967292 entRecno:
-294967292 memSeqno: 2 srcRecno: 0 srcCode: RMC memIdnum: 1002424
matchScore: 0 memStat: A srcFtime: Mon Dec 22 19:58:09 GMT+05:30 2003
srcLtime: Mon Dec 22 19:58:09 GMT+05:30 2003 recCtime: Mon Dec 22 19:58:09
GMT+05:30 2003 recMtime: Mon Dec 22 19:58:09 GMT+05:30 2003
class madison.mpi.MemAttr rowInd: A memRecno: -294967292 entRecno:
-294967292 memSeqno: 1 attrRecno: 0 asaIdxno: 0 attrCode: RACE attrName:
recStat: A srcFtime: Mon Dec 22 19:58:09 GMT+05:30 2003 srcLtime: Mon Dec 22
19:58:09 GMT+05:30 2003 recCtime: Mon Dec 22 19:58:09 GMT+05:30 2003
recMtime: Mon Dec 22 19:58:09 GMT+05:30 2003 attrVal: 04
class madison.mpi.MemName rowInd: A memRecno: -294967292 entRecno:
-294967292 memSeqno: 2 attrRecno: 0 asaIdxno: 0 attrCode: LGLNAME attrName:
recStat: A srcFtime: Mon Dec 22 19:58:09 GMT+05:30 2003 srcLtime: Mon Dec 22
19:58:09 GMT+05:30 2003 recCtime: Mon Dec 22 19:58:09 GMT+05:30 2003
recMtime: Mon Dec 22 19:58:09 GMT+05:30 2003 onmFirst: Shane onmMiddle:
onmLast: Kau Lee onmPrefix: onmSuffix: onmDegree: onmTitle:
** Mem Dump.