Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6617233
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:40:46+00:00 2026-05-25T20:40:46+00:00

Been searching for a solution for a while now, go to (1) or (2)

  • 0

Been searching for a solution for a while now,

go to (1) or (2) to skip description,
first i will explain the situation.

My firm have upgraded our erp. system, my primary work is to create lists used by others in the firm, i take all my data from this systems database
during upgrade we got some data converted to match the new version, some of it was left behind, some of it was not tampered with and just directly exported to the new database,
its on a separate server,
basically its a success, the new ERP. system works as supposed,
however a lot of my lists have been broken,
the data my lists use is missing/partly_missing/all_there

okay so the problem is missing data i need from the old database, okay a union on new and old database should be able to do that, however i do not want duplicate records, “data that was converted to the new database also exist in the old database” therefore two fields could exist “they do, i tried it”

so 2. version of my solution

i am lacking primary keys “iseries database” so i went concatting a combination of feilds making a uniqe key, “takes too long to explain how i did that”
however it ends up in me making a view with a union on two databases, making sure no records exist two times,

(1)
so this is what i got now,
a view of the combination of old and new table data
all built with checks on a “uniqe” key….
every time i need data that has been effected of the upgrade i must run a expensive query on each table, “some using these views more than 40 times”
(Question1) how can i “cost effective” take data from two different schemas/databases and bind together?

(2)
the only thing i can think of giving me this performance is to make indexes instead of these views that i built, however until now i haven’t been able to find any information on how to,
(Question2) Can i create a index over two tables,

my database is as/400 – iseries
however i am interested in a solution up against any database type,
i am very flexible with resources

:EDIT:
code that is used to create view with slight modification,

SELECT

CTCONO,
CTDIVI,
CTSTCO,
CTSTKY,
CTLNCD,
CTTX40,
CTTX15,
CTPARM,
CTTXID,
CTRGDT,
CTRGTM,
CTLMDT,
CTCHNO,
CTCHID

FROM NEWDB.CSYTAB
UNION
SELECT * FROM OLDDB.CSYTAB

WHERE ( CTCONO,CTDIVI,CTSTCO,CTSTKY,CTLNCD ) NOT IN
(
SELECT A.CTCONO,A.CTDIVI,A.CTSTCO,A.CTSTKY,A.CTLNCD FROM NEWDB.CSYTAB A, OLDDB.CSYTAB B
WHERE A.CTCONO = B.CTCONO
AND A.CTDIVI = B.CTDIVI
AND A.CTSTCO = B.CTSTCO
AND A.CTSTKY = B.CTSTKY
AND A.CTLNCD = B.CTLNCD

)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T20:40:47+00:00Added an answer on May 25, 2026 at 8:40 pm

    Make a new table that stores the value of your expensive query, then if you’re going to always ignore the older data in general if there’s a record in the new DB for it. Then just add in some triggers to update this new table when the other tables get updated.

    Perhaps, a better question would be to provide your schema, and current expensive query then ask for people to help make it faster.

    Edit: now you have posted your table I see one thing you could improve, make the second part of your query this:

    ...
    UNION
    SELECT * FROM OLDDB.CSYTAB B
    WHERE NOT EXISTS(
        SELECT TOP 1 1 
        FROM NEWDB.CSYTAB A
        WHERE A.CTCONO = B.CTCONO
            AND A.CTDIVI = B.CTDIVI
            AND A.CTSTCO = B.CTSTCO
            AND A.CTSTKY = B.CTSTKY
            AND A.CTLNCD = B.CTLNCD
        )
    

    Then provided you have a single index that spans { CTCONO,CTDIVI,CTSTCO,CTSTKY,CTLNCD } in the NEWDB.CSYTAB then it should be much better performance than what you’re getting currently.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been searching on the internet for a while now, for a solution
So I have been searching for a solution for this a while now, and
I have been searching for a solution for quite a while now and couldn't
I have been searching for a solution to this for a while and have
I've been searching for this solution for a while now... [bla bla... google.. bla]...
I have been searching for a solution for the past two days now. I
I've been struggling with this problem for a while now, searching every possible solution.
I have been searching for the solution to this problem for a while and
I've been searching for a solution to my problem for a long time now
I've been searching for a while and still can't find a simple solution to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.