Pass data from one dataset to another dataset which are not related in the layout in BIRT Report

firstDataSet has a simple query which returns a data that should be passed in the where clause of the secondDataSet. There are 2 tables in the layout (tied to each dataset), independent of each other. Below are the steps that I did,

First Data Set

  1. Declared a variable – variable1 with default value as 0
  2. SQL query defined in Open method.
  3. columns defined in Fetch method.
  4. onFetch method of the first dataset declared as – vars[“variable1”] = row[“column1”]

Second Data Set

  1. Defined the following line in beforeOpen – sqlText = this.sqlText.replace (“newclause”, Formatter.format(vars[“variable1″],”#” ));
  2. SQL query defined in Open method – select column2 from table1 where newclause
  3. Fetch method defined.

The SQL queries defined in both the data set is getting executed however the replace defined in the beforeOpen does not work. Please note that I cannot merge the dataset into 1 table in the layout ( this works but this does not inline with the requirement)

I guess that what you mean is a master-detail report, also called a sub-report in some tools.
For example, take the two tables PRODUCTLINES and PRODUCTS from the sample DB.
You want to show a kind of “product catalog”, grouped by product lines.
For each product line, you want to show the description and image for the productline, then list the products for this productline, and so on.

There are at least 3 different ways to achieve this, but one way which corresponds to what you describe is as follows.

You need two datasets, one for the PRODUCTLINES and one for PRODUCTS.
Name them accordingly.

The second one could look like this:

select * from PRODUCTS where PRODUCTLINE = ?

Note the question mark. This is called a bind variable.

Add a dataset parameter (input, type String) to this query which serves the purpose of supplying a concrete value for the bind variable when the query is executed. Give it a useful name, e.g. param_PRODUCTLINE.

In case of more than one bind variable: You need exactly as much data set parameters as there are question marks in the SQL.

In your layout, use a LIST item and bind it to the PRODUCTLINES.
Drag the PRODUCTLINE and the DESCRIPTION columns into the detail area of the list.

Next, drag the dataset “products” into the detail area.
This will create a TABLE item.
Name it accordingly, then open the “Binding” tab in the properties of the table. Click the button “Parameter Bindings”.
Here, edit the binding for the dataset parameter param_PRODUCTLINE and in the expression editor, enter row["PRODUCTLINE"] (you can also double-click it in the list of availale column bindings).

This way, for each PRODUCTLINE record, the value of its PRODUCTLINE column will be assigned to the bind variable param_PRODUCTLINE.

You should always prefer bind variables over manipulating SQL query text at run time, for security reasons (to avoid SQL injection!) and for performance reasons.

1

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật