Saturday, 13 December 2014

Standalone Rowset in Peoplecode


It’s a rowset that is outside of the component buffer and not related to the component presently being processed. Since it lies outside the data buffer, we will have to write PeopleCode to perform data manipulations like insert / update / delete.

Creation of Standalone Rowset

We use the below PeopleCode to create a standalone rowset. With this step, the rowset is just created with similar structure to that of the record SAMPLE_RECORD. However, the rowset would be empty at this point.

Local Rowset &rsSAlone;
&rsSAlone = CreateRowset(Record.SAMPLE_RECORD);

Populating  Standalone Rowset

Fill Method

&TRG_ID = '12345';
&rsSAlone.Fill("where TRAINING_ID = :1", &TRG_ID);

FillAppend Method

FillAppend is another method that we can use to populate a standalone rowset. This method appends the database records to the rowset starting from position of (last row + 1). Ie; it keeps the existing row intact and do not flush the rowset first like the Fill method.
&TRG_ID = '12345';
&rsSAlone.FillAppend("where TRAINING_ID = :1", &TRG_ID);

CopyTo Method

Local Rowset &rsSAlone2;
&rsSAlone2 = CreateRowset(Record.SAMPLE_RECORD);
&rsSAlone.CopyTo(&rsSAlone2);

Child Rowsets

Local Rowset &Lvl1, &Lvl2, &Lvl3;
&Lvl3 = CreateRowset(Record.SAMPLE_LVL3_REC);
&Lvl2 = CreateRowset(Record.SAMPLE_LVL2_REC, &Lvl3);
&Lvl1 = CreateRowset(Record.SAMPLE_LVL1_REC, &Lvl2);