In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
The content of this article mainly focuses on how to dynamically splice SQL according to the parameters in BIRT. The content of the article is clear and clear. It is very suitable for beginners to learn and is worth reading. Interested friends can follow the editor to read together. I hope you can get something through this article!
BIRT can use sql query to create datasets, pass client user input by setting parameters (Parameter) in the report, and set Dataset parameters and associate them with report parameters (these two parameters are different), so that client user input can be passed to Dataset parameters for use by sql query where statements, which is the usual practice of creating sql statements, but this method is only suitable for fixed sql statements. For stitching dynamic sql is not applicable.
For example, to deal with such a scenario: according to the incoming user name, start and end date, different order information is queried at different levels. Author stores user department information, account stores account information (multiple users can belong to one account, separated by commas), and META stores order details. The schematic diagram is as follows:
1. Pass in the login parameter login_user to determine the department level
2. When the level is manager, you need to obtain the current account in advance.
3. When the department is admin, count all accounts and user sales
4. When the department is manager, count the sales of the users under the current account.
5. When the department is engineer, only count its own sales
BIRT can be implemented in an indirect way: select the beforeOpen event in the Script page of DataSet, and write a JS script to dynamically stitch the SQL, similar to the following code:
...
Var query = "select ITEMS,USERS,sum (AMOUNT) as TOTALAMOUNT from META where ORDERDATE > =? and ORDERDATEB1=concat (sql," group by ITEMS,USERS\ "")
four
Else if flag== "manager"
> B1=concat (sql, "and ITEMS='", A1.query ("select accountid from account where find_in_set (?, limits)", login_user) .traditid, "'group by ITEMS,USERS\")
five
Else
> B1=concat (sql, "and USERS='", login_user, "'group by ITEMS,USERS\")
six
= A1.query@x (${B1}, startdate,enddate)
Thank you for your reading. I believe you have a certain understanding of the problem of "how to dynamically splice SQL according to parameters in BIRT". Go to practice quickly, if you want to know more related knowledge points, you can follow the website! The editor will continue to bring you better articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.