DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
Building Scalable Real-Time Apps with AstraDB and Vaadin
Register Now

Trending

  • Extending Java APIs: Add Missing Features Without the Hassle
  • Effortlessly Streamlining Test-Driven Development and CI Testing for Kafka Developers
  • Auditing Tools for Kubernetes
  • The SPACE Framework for Developer Productivity

Trending

  • Extending Java APIs: Add Missing Features Without the Hassle
  • Effortlessly Streamlining Test-Driven Development and CI Testing for Kafka Developers
  • Auditing Tools for Kubernetes
  • The SPACE Framework for Developer Productivity
  1. DZone
  2. Data Engineering
  3. Data
  4. Subquery From a Different Data Source in BIRT

Subquery From a Different Data Source in BIRT

In this brief article, see a solution to a problem involving a subquery from a different data source.

Jerry Zhang user avatar by
Jerry Zhang
CORE ·
Dec. 04, 19 · Code Snippet
Like (1)
Save
Tweet
Share
11.91K Views

Join the DZone community and get the full member experience.

Join For Free

Grayscale photo of laptop with code on the screen

Subquery From a Different Data Source in BIRT

The requirement is to have a query that is something like the following:

SELECT * FROM table1
WHERE oid in (
    SELECT * FROM table 2
    WHERE condition )


Table1 and table2 are on different databases. What can you do using the Eclipse BIRT environment?

You might also like:  How to Use a Subquery in MySQL

There are three traditional ways to solve the problem.

  1. Use something like a database link — Oracle Database Link. This way, you move the problem to the database level.

  2. Depending on the actual problem (read: the length of the “select oid FROM table2 where condition” results, you could use either a BIRT data cube or

  3. Use two DataSets and a layout structure list-table like this:

    • The two DataSets need different DataSources.

      • DataSet “T2_oids” with a query “select oid from table2 where condition”.
      • DataSet “T1_object” with a single parameter param_oid and a query “select * from table1 where oid = ?”.

Layout structure: * Outer ListItem “T2_oids” bound to DataSet “T2_oids” * Inner TableItem or ListItem “T1_object” bound to DataSet “T1_object” with the parameter bound to row[“oid”](or row[“OID”], use the list box). This item must be placed inside the T2_oids detail section. Since T1_object will return a single row, you can even use a GridItem instead of a TableItem or ListItem.

But if you have to take more compute actions, for example, sort the data by column “date” since they are sorted by key from original condition, even setting sorting filter on the BIRT output table doesn’t solve the problem. There’s a way around this sorting problem (by writing the outer results into a POJO (e.g. an ArrayList), then using a scripted dataset to finally sort the results. But this is getting too complicated.

4). Use esProc with BIRT.

Here is the SPL script.

Your BIRT reports can have a query from two data sources no matter what kind of database and go on other computations that are not convenient on BIRT. For a detailed SPL integration with BIRT, see How to Call an SPL Script in BIRT.

Further Reading

Getting Started With BIRT

How to Write Simple, Powerful Script Data Sources for BIRT Reports

Database Data (computing)

Published at DZone with permission of Jerry Zhang. See the original article here.

Opinions expressed by DZone contributors are their own.

Trending

  • Extending Java APIs: Add Missing Features Without the Hassle
  • Effortlessly Streamlining Test-Driven Development and CI Testing for Kafka Developers
  • Auditing Tools for Kubernetes
  • The SPACE Framework for Developer Productivity

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com

Let's be friends: