JOIN two (2) Datasets from different DB on BIRT Designer (v.4.4.0)

被刻印的时光 ゝ 提交于 2020-02-06 08:23:29

问题


I would like to ask about my problem that i faced these days during "designing" some reports with BIRT Designer (v.4.4.0). I tried making an UNION DATASET but that didnt work for me. I can make a SWITCH formula for Name and Surname from the workers but i have to write over 500 Names and Surnames with ID on the formel. So that technique doesnt work.

The Example is like this below. I have two databases and of course tables on it.

Database Name:   DB_1
Table Name:      Production

    Worker_ID     Machine_ID     Project     Good     Bad
    1188          001            Test_01      5        0
    1005          001            Test_01      6        0


and

Database Name:   DB_2
Table Name:      User

    Worker_ID     Name      Surname
    1188          John       Doe
    1005         Donald     Trump


I would like to show on table that info like this on BIRT Designer

Machine_ID    Project    Good    Bad    Worker_ID    Worker_Name    Worker_surname
001           Test_01     5       0        1188          John            Doe
001           Test_01     6       0        1005         Donald          Trump


Can anyone help me with SQL or with some tutorials about this problem?

If someone will help me with some Screenshots i would really appreciate it.


回答1:


First of all you need to have a database link on DB_1 or DB_2.

Assuming you have such a $ORACLE_HOME/network/admin/tnsnames.ora file for DB_2 :

DB_2 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = mydb2)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = bp83.mycompany.com)
    )
  )

Let's create a db-link on DB_1 targeting to DB_2 :

create public database link DB2_LNK
  connect to HR -- assumed schema name
  using 'mydb2:1521/bp83.mycompany.com';

and need an inner join query now (assuming you're on DB_1 then):

select p.machine_id as "Machine_ID", p.project as "Project", p.good as "Good", p.bad as "Bad", u.Worker_ID as "Worker_ID", u.Name as "Worker_Name", u.Surname as "Worker_surname" -- with formatted titles
  from Production p inner join hr.User_@DB2_LNK u  -- a keyword "user" cannot be used as a table name("ORA-00903: invalid table name" error raises when you attempt), so i assumed table name as "User_".
    on ( u.Worker_ID = p.Worker_ID )



回答2:


Use esProc with BIRT. Here is the SPL script.

        A
-----   -----
1       =Production=DB1.query(select * from Production)
2       =User=DB2.query(select * from User).keys(Worker_ID)
3       =Production.join(Worker_ID,User,Name:Worker_Name,Surname:Worker_Surname)

Your BIRT reports can have a query from two data sources no matter what kind of database. For detail SPL integration with BIRT, see How to Call an SPL Script in BIRT.



来源:https://stackoverflow.com/questions/48564496/join-two-2-datasets-from-different-db-on-birt-designer-v-4-4-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!