Kbase 16127: Validation May Cause Compile Errors When Splitting DB's
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  5/10/1998 |
|
Validation May Cause Compile Errors When Splitting DB's
INTRODUCTION
============
This knowledgebase entry discusses how splitting a single database
into multiple databases may cause compile errors when using
validation (data dictionary or general validation) because of
partial name matching.
WHY YOU NEED TO KNOW THIS
=========================
If your database has tables names that are partial names of
other database tables you need to be aware of this when designing
how a single database will be split into multiple databases.
AN EXAMPLE THAT FAILS
=====================
Consider the following example:
You have two databases, db1 and db2. db1 contains a customer
table and a table called tax-table. db2 contains a table called
tax.
When you try to compile the following code:
create customer.
update customer.tax-code
validate(can-find(first tax
where tax.tax-code = customer.tax-code),
"Invalid tax code").
you will get the following errors:
** Unknown Field or Variable name - tax-code. (201)
** Could not understand line 4. (196)
If you have the following in the data dictionary validation
for customer.tax-code:
CAN-FIND(first tax where tax.tax-code = tax-code)
and run the following code:
create customer.
update customer.tax-code.
you will get the following errors:
Unable to read Compiler Messages file.
** Unknown Field or Variable name - tax-code. (201)
** Unable to analyze dictionary validate expression for field .(575)
** Could not understand line 2. (196)
The reason the above occurs is because partial name matching applies
when multiple databases are connected. The preferred database which
is the database first checked in the absense of a database
qualification is the database that is being updated. So in the
example, db1 is the preferred database because the customer table
is being updated. When the compiler gets to "first tax where
tax.tax-code..." part of the can-find, it starts looking in the
preferred database, db1 for the closed match to "tax", and it finds
"tax-table" (by partial name match). Since the tax-code is not in
the tax-table, a compile error occurs. Progress always matches the
closest name in the closest database unless database names are
fully qualified.
In a single database, an exact name match holds precedance over a
partial name match. For this reason, the example above would
work fine if customer, tax, and tax-table were all in a single
database.
PROCEDURAL APPROACH
===================
One solution to this problem would be to qualify validation
with database names. However, this may not be good coding practice
in the case where data dictionary validation is being utilized.
A second solution would be to re-arrange the tables among the
databases so that tables with partial name matches are in the
same database.
Another solution would be to fix the table names so that no
partial matches could occur but this will probably require
many code changes.
Progress Software Technical Support Note # 16127