How logical relationships affect your programming

The calls you issue to process segments in logical relationships are the same calls that you use to process other segments. However, the processing is different depending on how the logical segment looks in your I/O area, what the DB PCB mask contains after a retrieve call, and how you can replace, delete, and insert physical and logical parent segments.

Because it is possible to access segments in logical relationships through the logical path or the physical path, the segments must be protected from being updated by unauthorized programs.

When DBAs define logical relationships, they define a set of rules that determine how the segments can be deleted, replaced, and inserted. Defining these rules is a database design decision. If your program processes segments in logical relationships, the DBA (or the person at your installation responsible for database design) should tell you:

  • What segments look like in your I/O area when you retrieve them
  • Whether your program is allowed to update and insert segments
  • What to do if you receive a DX, IX, or RX status code
The requirements for inserting a logical child segment are:
  • In load mode, the logical child can be inserted only under its physical parent. You do not supply the logical parent in the I/O area.
  • In update mode, the format of the logical child is different, depending on whether it is accessed from its physical parent or from its logical parent.
    • If accessed from its physical parent, the logical child's format is the concatenated key of the logical parent followed by intersection data.
    • If accessed from its logical parent, the logical child's format is the concatenated key of the physical parent, followed by intersection data.
  • The logical child can be inserted or replaced, depending on the insert rule for the logical or physical parent. Unless the insert rule of the logical or physical parent is PHYSICAL, the logical or physical parent must be supplied in the I/O area following the logical child.