Filelayout - ReadRowset Example

[From Peoplebook http://download.oracle.com/docs/cd/E15645_01/pt850pbr0/eng/psbooks/tpcr/book.htm?File=tpcr/htm/tpcr19.htm%23g037ee99c9453fb39_ef90c_10c791ddc07__1429]

ReadRowset Example

The following program reads all the rowsets from a file and updates a work scroll with that data. The work scroll isn’t hidden on the page: it’s created in the Component buffer from existing records using CreateRowset. The structure of the work scroll and the file layout are identical: that is, they’re composed of two records, and the names of the records in the file layout are exactly the same as the names of the record definitions.

Local File &CHARTINPUT_F; Local Rowset &INPUT_ROWSET, &TEMP_RS, &WORK_DATA; Local Record &WRK_DATA; &filename = "c:\temp\test.txt"; If FileExists(&filename, %FilePath_Absolute) Then &CHARTINPUT_F = GetFile(&filename, "R", "A", %FilePath_Absolute); Else Exit; End-If; &CHARTINPUT_F.SetFileLayout(FileLayout.CHART_INFO); /* Create rowset to be read into NOTE that you have to start at LOWEST level of rowset */ &TEMP_RS = CreateRowset(RECORD.CHART_ITEM); &WORK_DATA = CreateRowset(RECORD.CHART_DATA, &TEMP_RS); &INPUT_ROWSET = CreateRowset(RECORD.CHART, &WORK_DATA); While &INPUT_ROWSET <> Null &INPUT_ROWSET = &CHARTINPUT_F.ReadRowset(); &INPUT_ROWSET.CopyTo(&WORK_DATA); /* do processing -- Though file may contain more than one level zero Component processor only allows one level zero at a time */ End-While;

No comments: