Oui, j'ai besoin d'une solution
We've been working on a SQL report that iterates through all enabled Software Update Policies and provides the status (Enabled/Disabled) for each software advertisement within that policy(Software Update, Revised or Superseded). We believe we've gotten the code mostly right but having an issue adding the report to the SMP.
Keeps giving us an error:
"Query Validation failed. Report queries should not create, modify or delete persistent objects in the database."
Query is posted below and the only thing that might cause this error is our CASE statements but unsure.
-- Status of all Software Advertisements within all enabled Software Update Policies
SELECT DISTINCT
pol.Name AS [Software Update Policy],
-- iapol.Enabled AS [Policy Status],
-- iaadvert.Enabled AS [Advert Status],
CASE
WHEN iaadvert.Enabled = 1 THEN 'Enabled'
WHEN iaadvert.Enabled = 0 THEN 'Disabled'
ELSE '<<< Unknown >>>'
END
AS [Advert Status],
CASE
WHEN super.ParentResourceGuid IS NULL and iaadvert.Enabled = 0 THEN 'Revised'
WHEN super.ParentResourceGuid IS NOT NULL and iaadvert.Enabled = 0 THEN 'Superseded'
ELSE 'Software Update'
END
AS [Advert Status Reason],
-- super.ParentResourceGuid,
advert.Name AS [Advertisement Name],
advert.[CreatedDate] AS [Advert Create Date]
FROM Item Pol
JOIN ItemActive iapol
ON iapol.Guid = pol.Guid
JOIN ItemReference ir
ON ir.ParentItemGuid = pol.Guid
AND ir.Hint = 'swuadvert'
JOIN Item advert
ON advert.Guid = ir.ChildItemGuid
LEFT JOIN ItemReference ir2
ON ir2.ParentItemGuid = ir.ChildItemGuid
AND ir2.Hint = 'swu'
LEFT JOIN ResourceAssociation super
ON super.ChildResourceGuid = ir2.ChildItemGuid
AND super.ResourceAssociationTypeGuid = '644A995E-211A-4D94-AA8A-788413B7BE5D'--Software Component Supersedes Software Component
JOIN ItemActive iaadvert
ON iaadvert.Guid = advert.Guid
--WHERE iapol.enabled IS NOT NULL
WHERE iapol.Enabled = 1
AND iaadvert.Enabled IS NOT NULL
-- AND super.ParentResourceGuid IS NOT NULL
ORDER BY 1 DESC,2 DESC, 3
0