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

  • SEARCH
  • Home
  • 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 6321149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:05:59+00:00 2026-05-24T16:05:59+00:00

I have a two tables (actually sets of tables) which may need to be

  • 0

I have a two tables (actually sets of tables) which may need to be kept in sync (The first set of tables I need all the data replicated to the second set where this data will be a subset).

If why matters (perhaps because it is obviously not very good form having replicated data) see (very bottom of this other question under the ‘PS‘ section): DB2 update and insert trigger, references a lot of fields can I use * to shorten them (in iSeries but might not matter)

To do this I’m placing insert, update and delete triggers on what I’ll call the ‘primary set’ which will insert, update and delete records onto the ‘replicated set’.

My question is what if I want to now keep the replicated set in sync with the primary set? I’m looking at documentation right now to see the best way to do this. I don’t want an insert trigger to try to insert into what ever table was initially inserted into, as this I expect will cause an error which would be reported back to the program making the insert, unless there is a way in the trigger to throw out such reporting? The best way at this time looks like checking if the record exists before the delete, same for insert.

Then there is the issue of recursing on an update trigger, I was wondering if there is more elegant solution than checking if the values are the same and then not updating?

The primary set can not be changed in any way (excepting triggers which do not modify input/output from the table in any way), while the schema of the replicated set is completely flexible.

Optimize for lazyness (I’m probably going to automate the creation of these triggers but if you have suggestions on how to keep them compact it will speed up my development).

The system is not heavily used, it has a tone of free resources… there is little need to be conservative with memory, processing and disk space.

  • 1 1 Answer
  • 3 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-24T16:06:00+00:00Added an answer on May 24, 2026 at 4:06 pm

    Instead of using replicated tables, you’re going to be far better off using views. This will allow you to completely decouple your database access from your underlying database design. With a combination of updateable/deletable views and ‘instead-of’ triggers, you should be able to do things nicely. Keep in mind that this is the recommended setup, even if you’re using only SQL (and in any language) as it allows you to decouple program design from database design. The fact that it allows you to decouple from iSeries PFs is just a bonus.

    Good news – you don’t have to switch everything to use SQL just yet – the iSeries is actually setup to allow you to access SQL objects (like views and triggers) as if it was a physical file, with native RPG file access.
    Bad news – unlike logical files, views can’t be ordered. If you’re using a lot of keyed access over logical files, your efforts could be complicated… I haven’t tried accessing an SQL index with a CHAIN operation to see if it gives me access to the rest of the record, so I have no idea if that will work.


    EDIT:

    Finally got around to testing this. It turns out that accessing indexes for their ordering (as if for a keyed logical file) will indeed grant access to the rest of the record. Not sure if that helps you or not.

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

Sidebar

Related Questions

I have two tables. First table is je_addchoice , which contains fields like choiceid
I have two tables, XMLtable and filterTable . I need all the XMLtable.ID values
I have two tables in my MySQL database, one is a library of all
I have two tables set up in a many-to-many relationship: Incidents and Users. When
I have two tables that need to be updated, Master and Identifiers: Master --MasterID
I have two tables that contain data from different temperature sensors: Table1 _TimeStamp Temperature
I have two tables. Widgets, which has information about each widget (Color, size, etc);
I have two tables one named Person , which contains columns ID and Name
Here's the situation. I have two sets of data. One is a list of
I have two tables with hierarchyid fields, one of which is a staging table

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.