Warning Message: Field xxx causes duplicate database data

0 Likes

This article describes the cause of this compile time warning message and what you can do to resolve the problem.

Problem:

Compiling a COBOL program using the CREATEXFD directive can result in the generation of the compile time warning message “Field xxx causes duplicate database data.” The condition that causes this compile time warning to be generated is described in the Database Connectors User’s Guide, section "Performance and Troubleshooting."

This warning can occur when you compile with the CREATEXFD directive. The XFD will be built and the Connector will operate correctly. However, the warning informs you of a special database situation that is not advisable. This warning means that your record definition should be restructured.

Your current definition is set up in such a way that both of the following are true:


  • You have overlapping key fields
  • Both keys must be represented in the database as separate items

Database Connectors™ will handle this situation correctly. It will keep the overlapping keys updated simultaneously, so that they always have the same value. However, the warning alerts you that you have the same data represented twice in the database. This is dangerous, because someone might access the database via SQL and accidentally change only one of the keys.

Here's an example of the problem and a description of how to correct it (the example assumes that both key-1and key-2 have been declared as keys):

01  order–record.
03 key–1.
05 field–a pic x(5).
05 field–b pic 9(5).
05 key–2
redefines field–b pic x(3).

This example will generate the warning message.

Because key-2 is a key, it must also be represented in the database. Because it doesn't correspond exactly to any other data field, it must be entered as a separate column in the database.

In the COBOL view of the file, key-1and key-2 overlap. But the requirements of database storage force the same data (known to COBOL as field-b) to be physically represented twice in the database. Any updates to the data from any Net or Server Express COBOL program will correctly update both columns. Updates from outside of Net or Server Express, however, carry no such guarantee.

Resolution:

In this example, you can correct the situation by breaking field-b into two columns, so that key-2 corresponds exactly to another data field:

01  order–record.
03 key–1.
05 field–a pic x(5).
05 field–b.
07 field-b1 pic x(3).
07 field-b2 pic 9(2).
05 key–2
redefines field–b pic x(3).
Old KB# 14266
Comment List
Anonymous
Related Discussions
Recommended