将动态参数传递给水晶报表中的存储过程 [英] Passing a dynamic parameter to a stored procedure in crystal reports
问题描述
我有一个来自我的ERP供应商的水晶报告,我正在尝试添加一个字段,该字段存在于一个表中,该表不是报告当前使用的表之一。
编辑此报告以添加所需的表不是一个简单的任务,因此可以包含该字段,所以我想也许我可以在报表中添加一个存储过程并传递给它作为报告一部分的字段,它将为我提供我想要包含的字段值。
这是,对于每个记录,如果显示在报告中,则会调用存储过程从每条记录传递一个字段,然后我将返回我想要包含在报告中的附加字段。
您是否可以将动态参数传递给CR中不是报表参数的存储过程?
我尝试过:
I have a crystal report from my ERP vendor and I am trying to add a field to it that exists in a table that isn't one of the tables currently being used by the report.
It is not a simple task of editing this report to add the required tables so the field can be included, so I thought that perhaps I could add a stored procedure to the report and pass to it one of the fields that is part of the report, which it turn would provide me with the field's value that I want to include.
This is, for every record that is being displayed in the report, the stored procedure would be called passing a field from each record, and I would get back the additional field I want to include in the report.
Can you pass a dynamic parameter to a stored procedure in CR that isn't a report parameter ?
What I have tried:
CREATE PROCEDURE [dbo].[q_GetCOO_byItemID]
@ItemID varchar(max)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
select country_of_origin from inventory_supplier
inner join inventory_supplier_x_loc
on inventory_supplier_x_loc.inventory_supplier_uid = inventory_supplier.inventory_supplier_uid
inner join inventory_supplier_trade
on inventory_supplier_trade.inventory_supplier_uid = inventory_supplier.inventory_supplier_uid
inner join inv_mast
on inv_mast.inv_mast_uid = inventory_supplier.inv_mast_uid
where inv_mast.item_id = @ItemID and primary_supplier = 'Y' and location_id = '10'
END
推荐答案
你的主报告是否有itemID?如果是,那么您可以使用存储过程创建子报表,方法是将主报表ItemID链接到子报表@itemID参数,然后您可以在supreport中使用共享变量使主报表中的必填字段可用
Does your main report has itemID?? If yes then u can create a subreport using Stored Procedure by linking the main report ItemID to subreport @itemID Parameter and then u can use shared variable in supreport to make that required field available in main report
这篇关于将动态参数传递给水晶报表中的存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!