Results 1 to 7 of 7
  1. #1
    Join Date
    Nov 2008
    Posts
    4

    Unanswered: Conensing multiple queries into one.

    Hi.

    This may be a pretty simple question, but I'm pretty new to DB2 and SQL. Let's say I have an ordered list of employee performance reports. These reports have an employee ID number, but no name. I want to query my EMPLOYEES table and retrieve the name that matches each ID. Right now, I'm doing this using a Java loop that executes a separate SELECT statement to retrieve each record. I feel like this is a horribly inefficient way to do things, and am hoping there is some way to pass an ordered list of parameters into a query and retrieve a similarly ordered result set. Suggestions?

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    Quote Originally Posted by aadwight
    Suggestions?
    http://mysite.verizon.net/Graeme_Birchall/id1.html
    ---
    "It does not work" is not a valid problem statement.

  3. #3
    Join Date
    Nov 2008
    Posts
    4
    Thanks, that looks very useful...but I'm not sure which of those 450+ pages answers my question.

  4. #4
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    I'd start with concepts. What you are after is called a join.
    ---
    "It does not work" is not a valid problem statement.

  5. #5
    Join Date
    Nov 2008
    Posts
    4
    I might have phrased my problem poorly. I actually might have asked the wrong question entirely.

    What I actually have is an Oracle database with some data (performance reports), and a DB2 database with some other data (employee names). If there's a way to join those two tables, that would be exactly what I want to do. I thought this was impossible, but further research shows that I might have been mistaken. So, should I just look further into how to do that, or is there another possible solution?

  6. #6
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    Depending on what you are more comfortable with, you could set up a federated database (from the DB2 side) or a database link (from the Oracle side) to reach to the other database. Both these solutions require additional software: Websphere Information Integrator (or whatever it is called these days) or Oracle Heterogenous Services respectively.

    As an alternative, you could use an MS Access database to pull data from both sources via ODBC.
    ---
    "It does not work" is not a valid problem statement.

  7. #7
    Join Date
    Nov 2008
    Posts
    4
    I was afraid you might say something like that.

    I'll have to check tomorrow to see if I have any of that software. I'm afraid I don't have an MS Access database to play with, so that one's not going to happen. In the meantime, I have a few ideas about how I might be able to cut down on the number of DB2 calls from the Java side of things. Thanks for your help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •