Update with join not working

Hello,

I created a job to fix a data issue by getting the correct value from a view that had been modified but it’s not doing the update. Please let me know if you can tell what I’m doing wrong.

Thank you

static

void

XTRA_Update_Asset_Departments(Args _args)

{

XTRAAssetMonthlyReport XTRAAssetMonthlyReport;

XTRA_AssetDimensions XTRA_AssetDimensions;

while select forUpdate

XTRAAssetMonthlyReport

join

XTRA_AssetDimensions

where

XTRAAssetMonthlyReport.AssetId == XTRA_AssetDimensions.AssetId

{

ttsBegin

;

if

(XTRAAssetMonthlyReport.DepartmentId != XTRA_AssetDimensions.DepartmentId)

{

info(

"AssetId "

  • XTRAAssetMonthlyReport.AssetId);

XTRAAssetMonthlyReport.DepartmentId = XTRA_AssetDimensions.DepartmentId;

}

XTRAAssetMonthlyReport.update();

ttsCommit

;

Can you tell us a bit about the current behavior (e.g whether you’re getting any error)? “It’s not doing the update” can mean a lot of things.

I would expect the problem in the fact that you’re trying to select data for update before actually starting a transaction.

(By the way, could you also remove all excessive line breaks from your code snippet? Many thanks.)