static void CopyPersistedTableToInMemoryJob(Args _args)
{
CustTable custTable;
CustTable custTmpLedger;
custTmpLedger.setTmp();
custTable.recordLevelSecurity(true);
while select * from custTable where custTable.AccountNum like '1*'
{
custTmpLedger.data(custTable.data());
custTmpLedger.doInsert();
info(strFmt("Inserted a row for AccountNum = %1",custTable.AccountNum));
}
custTmpLedger = null;
}
The code copies data from the CustTable into an InMemory table.The setTmp method is used to create the same structure as it is on the physical table. The method changes the value from TableType::regualar to TableType::InMemory. A TempDB table is instantiated in the underlying database management system when the first SQL operation is sent to the database system from the AOS. The SQL operation can be either select, insert, update, or delete.
Variable goes out of scope. The typical case is that a method declares a variable for the particular TempDB type. The method inserts data into the TempDB table. The insert causes the table to be instantiated in the database. When the method finishes, all variables declared in the method go out of scope. The AOS tells the database system to drop the TempDB table when its corresponding variable does out of scope.
Create a TestTmp as InMemory table with Id a string type as a field.
static void TestTmpInMemory(Args _args)
{
TestTmp tmp1, tmp2;
;
tmp1.Id = "1000";
tmp1.insert();
tmp2.setTmpData(tmp1);
info("Tabletype: " + enum2Str(tmp1.getTableType()));
info("tmp1data begin: ");
while
select tmp1
info(" Id " + tmp1.ID);
info("tmp1data end.");
info("tmp2 data begin: ");
while
select tmp2
info(" Id " + tmp2.ID);
info("tmp2 data end.");
}
No comments:
Post a Comment