Helllo,
I have following query:
IF (@OrgIDs) not in (@Platce)
SELECT TOP 100
PRI.sym AS [Category]
,CR.ref_num as Incident
,ORG.org_name as Organizace
, CR.persid AS ViolationIncidetID
,SRVCAT.SrvCatDesc
,ORGCAT.OrgCatID
FROM call_req AS [CR] with (nolock)
LEFT JOIN dbo.pri AS [PRI] ON CR.priority=PRI.enum
LEFT JOIN dbo.prob_ctg AS CAT ON CR.category = CAT.persid
left outer join srv_desc as SRV on CAT.service_type=SRV.persid
LEFT JOIN dbo.ca_contact AS CT ON CR.customer = CT.contact_uuid
LEFT JOIN dbo.ca_organization AS ORG ON CT.organization_uuid = ORG.organization_uuid
INNER JOIN data_ware.dbo.OrganizationCategory_v4 AS ORGCAT
ON CT.organization_uuid = ORGCAT.OrgID and '2014' = cast (ORGCAT.OrgCatID /10000 as int)
INNER JOIN data_ware.dbo.ServiceCategory_v4 AS SRVCAT
ON SRV.id = SRVCAT.ServiceID and '2014' = cast (SRVCAT.SrvCatID /10000 as int)
left join data_ware.dbo.MUST_OrganizationServiceLink_v2 as TEST on SRVCAT.SrvCatID=TEST.IDsvc
WHERE
({fn ifnull(CR.z_close_date,CR.close_date)}>=dbo.AC_timestamp_from_datetime(DATEADD(d, DATEDIFF(d, 0, @Datum_od), 0)) AND {fn ifnull(CR.z_close_date,CR.close_date)}<=dbo.AC_timestamp_from_datetime(DATEADD(d, DATEDIFF(d, 0,@Datum_do)+1, 0)))
AND SRVCAT.SrvCatID IN (@ServiceCategoryIDs)
AND ORGCAT.OrgCatID IN (@OrgIDs)
and CR.[type] = 'I'
else
SELECT TOP 100
PRI.sym AS [Category]
,CR.ref_num as Incident
,ORG.org_name as Organizace
, CR.persid AS ViolationIncidetID
,SRVCAT.SrvCatDesc
,ORGCAT.OrgCatID
,SRVCAT.SrvCatID
FROM call_req AS [CR] with (nolock)
LEFT JOIN dbo.pri AS [PRI] ON CR.priority=PRI.enum
LEFT JOIN dbo.prob_ctg AS CAT ON CR.category = CAT.persid
left outer join srv_desc as SRV on CAT.service_type=SRV.persid
LEFT JOIN dbo.ca_contact AS CT ON CR.customer = CT.contact_uuid
LEFT JOIN dbo.ca_organization AS ORG ON CT.organization_uuid = ORG.organization_uuid
INNER JOIN data_ware.dbo.OrganizationCategory_v4 AS ORGCAT
ON CT.organization_uuid = ORGCAT.OrgID and '2014' = cast (ORGCAT.OrgCatID /10000 as int)
INNER JOIN data_ware.dbo.ServiceCategory_v4 AS SRVCAT
ON SRV.id = SRVCAT.ServiceID and '2014' = cast (SRVCAT.SrvCatID /10000 as int)
left join data_ware.dbo.MUST_OrganizationServiceLink_v2 as TEST on SRVCAT.SrvCatID=TEST.IDsvc
WHERE
({fn ifnull(CR.z_close_date,CR.close_date)}>=dbo.AC_timestamp_from_datetime(DATEADD(d, DATEDIFF(d, 0, @Datum_od), 0)) AND {fn ifnull(CR.z_close_date,CR.close_date)}<=dbo.AC_timestamp_from_datetime(DATEADD(d, DATEDIFF(d, 0,@Datum_do)+1, 0)))
and CR.[type] = 'I'
AND SRVCAT.SrvCatID IN (@ServiceCategoryIDs)
AND (ORGCAT.OrgCatID IN (@OrgIDs) or (/*(@OrgIDs) in (@Platce) and*/ TEST.IDPlatce in (@Platce) and (ORGCAT.OrgCatID not in (select T2.IDorg from data_ware.dbo.MUST_OrganizationServiceLink_v2 as T2 where T2.IDsvc in (@ServiceCategoryIDs)))))
@OrgIDs, @ServiceCategoryIDs, @Platce are multivalue parameter based on queries. @ServiceCategoryIDs is based on @OrgIDS and @Platce is based on both.
When I run report with only one value in @OrgIDS and multivalues in other parameters then reports run correctly. When I have more then one value in @OrgIDS parameter then report doesn't run and I get following error message
|
Don't you know what to do? I am looking forward for your ideas.
Thanks
Lukas


