2 回答

TA貢獻1155條經驗 獲得超0個贊
最簡單的修復方法是使用 COALESCE(templates.L2Name, '') 將可為空的列包裝在您的 sql 語句中,
? sqlstatement := "SELECT" +
? ? " assets.ID, assets.Name, assets.LastCheckIn, assets.Status, assets.OffTimer," +
? ? " assets.SafetyTimer, assets.HazardTimer, assets.HazardTimerStartedTime, assets.LastSignedOn," +
? ? " assets.Latitude, assets.Longitude, assets.TemplateID, assets.ActiveDeviceType, assets.CurrentDeviceID," +
? ? " assets.OffTimerTemp, assets.OrganisationID," +
? ? " organisations.Name As OrganisationName," +
? ? " devices.Label As CurrentDeviceName," +
? ? " templates.Name As TemplateName, COALESCE(templates.L2Name, ''), COALESCE(templates.L2Contact, '')," +
? ? " COALESCE(templates.L3Name, ''), COALESCE(templates.L3Contact, '')," +
? ? " COALESCE(templates.L4Name, ''), COALESCE(templates.L4Contact, ''), templates.Note" +
? ? " FROM assets" +
? ? " LEFT JOIN organisations ON assets.OrganisationID = organisations.ID" +
? ? " LEFT JOIN devices ON assets.CurrentDeviceID = devices.ID" +
? ? " JOIN templates ON assets.TemplateID = templates.ID" +
? ? " WHERE assets.Status != 'Not monitoring' AND assets.AssetStatus = 'Active' AND assets.Display != '0'"
- 2 回答
- 0 關注
- 195 瀏覽
添加回答
舉報