Цитата:
Сообщение от
fed
Нет под рукой DAX2012, поэтому хочу спросить - там что - реально forceliterals стоял в коде ? (Просто я наверное и не вспомню на вскидку, где в стандарте forceliterals прописан был в DAX2012...)
Не, там прямой запрос к БД.
X++:
private static server boolean updateDistributionsForEvent(recId _accountingEventRecId, AccountingDate _accountingDate, recId _sourceDocumentRecId)
{
str sqlStatementText;
str sqlDate = date2str(_accountingDate, 321, 2, 3, 2, 3, 4, DateFlags::None); // 'YYYY-MM-DD'
// Do the update as direct SQL as there is a deadlock on AccountingDistribution due to a clustered
// index scan operator in the query plan. This operator appears only in low data volume scenarios.
// In higher volume scenarios, the plan includes a seek operator using the index I_7452SOURCEDOCUMENTHEADERIDX.
// Testing in SSMS indicates an index hint will correct the plan at low volumes and represents minimal
// risk at high volumes. In order to enable the index hint on the update_recordset, direct SQL must be used.
// Also note that xGlobal::randomPositiveInt32() is the method used by the kernel to populate the
// recversion field.
sqlStatementText = strFmt('UPDATE T1 SET ACCOUNTINGEVENT=%1,RECVERSION=%2 FROM ACCOUNTINGDISTRIBUTION T1 WITH (INDEX(I_7452SOURCEDOCUMENTHEADERIDX)) CROSS JOIN SOURCEDOCUMENTLINE T2 ', _accountingEventRecId, xGlobal::randomPositiveInt32());
sqlStatementText += strFmt('WHERE (((T1.PARTITION=%1) AND (T1.ACCOUNTINGEVENT=0) AND (T1.ACCOUNTINGDATE={ d\'%2\'})) AND (T1.SOURCEDOCUMENTHEADER=%3)) AND ', getcurrentpartitionrecid(), sqlDate, _sourceDocumentRecId);
sqlStatementText += strFmt('((T2.RECID=T1.SOURCEDOCUMENTLINE) AND (T2.ACCOUNTINGSTATUS=%1 OR T2.ACCOUNTINGSTATUS=%2)) AND (T2.PARTITION=%3)', enum2int(SourceDocumentLineAccountingStatus::Completed), enum2int(SourceDocumentLineAccountingStatus::Canceled), getcurrentpartitionrecid());
return AccountingEventSourceDocumentProcessor::executeSQL(sqlStatementText);
}