Consultor Eletrônico



Kbase 19269: Find fails if index is not assigned - Error (565)
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   18/11/1999

This document applies to: Progress' Default Write behavior
Version and Release Number: All

Summary:

This note is intended to point out a feature of the product that is not well known or documented, but can potentially affect application development efforts.

When a record is created in a Progress Database and it's Primary Index is not assigned, or is only partially assigned, Progress doesn't release that record for other buffers to access until it has been explicitly released.

The following procedure demonstrates creating a record without assigning a value to it's primary index. This example uses the Benefits table in the Sports2000 DB:

/* Procedure crbens.p */

DEFINE BUFFER bBens FOR Benefits.

CREATE Benefits.
ASSIGN DependentCare = 999
HealthCare = STRING(RANDOM(1,9))
LifeInsurance = 999
MedicalSpending = 645
Pension401K = 65465
StockPurchase = 3245435.

FIND FIRST bBens WHERE bBens.HealthCare = Benefits.HealthCare.

/* End crbens.p */

The find statement will return the following error:
**FIND FIRST/LAST failed for table Benefits. (565)

The most essential thing to remember is that, when a new record is created, PROGRESS does not release it until it's index has been created. In the case of the above code, the only index in the benefits table is the EmpNo Index, this contains the field EmpNum. Note that this field was not assigned. Thus any attempts to access the newly created record through a defined buffer fail.

This is most tricky where multi-part indexes are concerned.
In the below example the SupplierItemXref table has a multi-part
index(Composed of "Itemnum and "SupplierIDNum"). This procedure creates a new record in the table and only assigns the first field in the index("Itemnum"), leaving "SupplierIDNum" unassigned. Again an attempt access the newly created record with a defined buffer fails.

/* Procedure crsupxref.p */
DEFINE BUFFER bXref FOR SupplierItemXref.

CREATE SupplierItemXref.
ASSIGN Itemnum = INTEGER(STRING(RANDOM(1,9)) +
STRING(RANDOM(1,9)) +
STRING(RANDOM(1,9)) +
STRING(RANDOM(1,9)) +
STRING(RANDOM(1,9))).

FIND FIRST bXref WHERE bXref.Itemnum = SupplierItemXref.Itemnum.
/* End crsupxref.p */

There are a number of ways to release the record including:

1. The RELEASE statement.
Syntax = Release SupplierItemXref.
This would be issued directly after the ASSIGN statement.
2. The FIND CURRENT with NO-LOCK.
Syntax = "FIND CURRENT SupplierItemXref NO-LOCK".
This would be issued directly after the ASSIGN statement.
3. Enclose the CREATE and ASSIGN statements in a transaction block.
DO TRANSACTION:
CREATE ...
ASSIGN ....
END.