Monday, July 23, 2012

How to Use Temporary Table in Form

Temporary table(Table whose property temporary set to "yes") is not persistent media , so at run-time you have to populate the temporary table and attach the same to the form/report. For illustration purpose ,I am using inventTable data and attaching the items whose group is Parts.
1. Create temporary table as TmpTestTable with 3 fields(ItemId,Itemname,ItemGroup).
2. Create a form as TempTestTable and attach the table as datasource
3. Create a new method on the form and copy the following code
TmpTestTable populateRecords(ItemGroupId _itemGroupId)
TmpTestTable tmpTable;
InventTable inventTable;
while select inventTable
where inventTable.ItemGroupId == _itemGroupId
tmpTable.Itemid = inventTable.ItemId;
tmpTable.ItemName = inventTable.ItemName;
tmpTable.Itemgroup = inventTable.ItemGroupId;
return tmpTable;
4. Call the above method in init() after super as below public void init()
// Call the setTmpData method to attach records to datasource

No comments: