我知道其他人也提出了类似的问题,但我已经尝试过他们的解决方案,但它仍然不适合我。
我有一个名为“Region”的参数,它使用“region”数据集和另一个名为“Office”的报告参数,该参数使用“office”数据集。
现在我希望根据“区域”选择过滤“Office”值列表。这是我到目前为止所做的。对于区域数据集,它返回“regions_id”和“region_description”。然后,对于“Region”报告参数,我选择了“Text”数据类型并允许Null值。选择“text”可能是一个错误,因为这是一个uniqueidentifier值。对于可用值,我选择了区域数据集和regions_id作为value,region_description作为标签。我转到高级选项卡并选择“始终刷新”。在默认选项卡上,我输入了“(空)”,因为他们想要查看所有区域。
NExt,我创建了一个名为“regions_id2”的报告参数,允许空值,并设置了可用值=区域数据集。对于值和标签两者,我指定了regions_id。对于默认值,我再次输入“(Null)”。我再次选择“永远刷新”。
最后,我将“regions_id2”参数添加到“office”数据集中。然后office报告参数使用具有可用值的“office”数据集。值字段=“group_profile_id”和标签字段=“name_and_license”。默认值=“(空)”。高级“永远刷新”。
我按照相同的顺序订购了这些报告参数:Regions,regions_id2和Office。但是现在当我运行这份报告时,我没有任何错误,但办公室列表包括所有办公室,无论我为区域选择什么。这是我对这些数据集的T-SQL:
CREATE Procedure [dbo].[rpt_rd_Lookup_Regions]
(
@IncludeAllOption bit = 0,
)
As
SET NOCOUNT ON
If @IncludeAllOption = 1
BEGIN
Select Distinct
NULL AS [regions_id],
'-All-' AS [region_description]
UNION ALL
SELECT Distinct
[regions_id],
[region_description]
FROM [evolv_cs].[dbo].[regions]
Where [region_description] not in ('NA','N/A')
Order By [region_description]
END
Else
BEGIN
SELECT Distinct
[regions_id],
[region_description]
FROM [evolv_cs].[dbo].[regions]
Where [region_description] not in ('NA','N/A')
Order By [region_description]
END
CREATE Procedure [dbo].[rpt_rd_Lookup_Facilities]
(
@IncludeAllOption bit = 0,
@regions_id uniqueidentifier = NULL
)
As
SET NOCOUNT ON
If @IncludeAllOption = 1
BEGIN
Select
Null As [group_profile_id],
Null As [profile_name],
Null As [license_number],
Null As [other_id],
--Null As [Regions_id],
'-All-' As [name_and_license]
UNION ALL
SELECT
[group_profile_id],
[profile_name],
[license_number],
[other_id],
--[regions_id],
[profile_name] + ' (' + LTRIM(RTRIM([license_number])) + ')' As [name_and_license]
FROM [evolv_cs].[dbo].[facility_view] With (NoLock)
Where [is_active] = 1 and (@regions_id is NULL or @regions_id = [regions_id])
Order By [profile_name]
END
Else
BEGIN
SELECT
[group_profile_id],
[profile_name],
[license_number],
[other_id],
[regions_id],
[profile_name] + ' (' + LTRIM(RTRIM([license_number])) + ')' As [name_and_license]
FROM [evolv_cs].[dbo].[facility_view] With (NoLock)
Where [is_active] = 1 and (@regions_id is NULL or @regions_id = [regions_id])
Order By [profile_name]
END
我可能做错了什么?
答案 0 :(得分:0)
我通过从办公室数据集的区域数据集中选择区域参数值来修复此问题