Announcements
[DataSource] class MyTempDBTable { ////// Init of TempDB Datasource of FormB /// public void init() { super(); FormRunDataHelper callerDataHelper = element.args().caller().dataHelper(); FormDataSource callerFormDataSource = callerDataHelper.FindDataSource(tableStr(myTempDBTable)); //RecID is correctly filled RefRecId currentRecid = callerFormDataSource.cursor().RecId; if(callerFormDataSource && currentRecid) { //Add query range SysQuery::findOrCreateRange(this.queryBuildDataSource(), fieldNum(myTempDBTable, RecId)).value(SysQuery::value(currentRecid)); //Copy content of the buffer and link it to the current buffer MyTempDBTable myTempDBTableLocal = callerFormDataSource.cursor().data(); MyTempDBTable.linkPhysicalTableInstance(myTempDBTableLocal); } } }
Runtime error on line MyTempDBTable.linkPhysicalTableInstance(myTempDBTableLocal):
Cannot execute the required database operation. The method is only applicable to TempDB table variables that are not linked to existing physical table instance
[Form] public class DMFEntityTemplateDefinitionLoadDialog extends FormRun { private DMFEntityTemplateDefinitionLoad entityTemplateDefinitionLoad; public void init() { super(); if (this.args() == null || !(this.args().caller() is DMFEntityTemplateDefinitionLoad)) { throw error(Error::wrongUseOfFunction(funcName())); } entityTemplateDefinitionLoad = this.args().caller(); DMFEntityTemplateDefinitionTmp.linkPhysicalTableInstance(DMFEntityTemplateDefinitionTmp::generateTmpData()); } //more code }
- MyTempDBTable.linkPhysicalTableInstance(myTempDBTableLocal); MyTempDBTable.setTmp(callerFormDataSource.cursor());
[DataSource] class MyTempDBTable { ////// Sync caller FormDatasource with this FormDatasource /// public void init() { super(); if(!this.canSyncFormDatasource()) { return; } FormRunDataHelper callerDataHelper = element.args().caller().dataHelper(); FormDataSource callerFormDataSource = callerDataHelper.FindDataSource(tableStr(MyTempDBTable)); RefRecId currentRecid = callerFormDataSource.cursor().RecId; if(callerFormDataSource && currentRecid) { //Sync InMemory callerDatasource to this form MyTempDBTable.setTmpData(callerFormDataSource.cursor()); //Update ranges SysQuery::findOrCreateRange(this.queryBuildDataSource(), fieldNum(MyTempDBTable, RecId)).value(SysQuery::value(currentRecid)); //Set cursor to original caller cursor position this.executeQuery(); element.args().lookupRecord(callerFormDataSource.cursor()); MyTempDBTable_ds.research(false); } } protected boolean canSyncFormDatasource(Args _args = element.args()) { if(!element.args()) { return false; } if(!element.args().caller()) { return false; } if(element.args().callerType() != UtilElementType::Form) { return false; } if(element.args().callerType() != UtilElementType::Form) { return false; } if(element.args().callerType() != UtilElementType::Form) { return false; } return true; } //Additional methods }
Hi,
Declare the buffer for temp table in the form declaration globally and try the same.
[Form] public class FormName extends FormRun { MyTempDBTable myTempDBTableLocal [DataSource] class MyTempDBTable { ////// Init of TempDB Datasource of FormB /// public void init() { super(); FormRunDataHelper callerDataHelper = element.args().caller().dataHelper(); FormDataSource callerFormDataSource = callerDataHelper.FindDataSource(tableStr(myTempDBTable)); //RecID is correctly filled RefRecId currentRecid = callerFormDataSource.cursor().RecId; if(callerFormDataSource && currentRecid) { //Add query range SysQuery::findOrCreateRange(this.queryBuildDataSource(), fieldNum(myTempDBTable, RecId)).value(SysQuery::value(currentRecid)); //Copy content of the buffer and link it to the current buffer myTempDBTableLocal = callerFormDataSource.cursor().data(); MyTempDBTable.linkPhysicalTableInstance(myTempDBTableLocal); } } } }
Thanks,
Girish S,
André Arnaud de Cal...
294,033
Super User 2025 Season 1
Martin Dráb
232,854
Most Valuable Professional
nmaenpaa
101,158
Moderator