Previous Topic: WITHIN AREANext Topic: CURRENT


DB-KEY and ACCEPT

If the database key of a record is known, the record can be retrieved directly with the FIND/OBTAIN DB-KEY function. If the db-key is not known, the ACCEPT function can be used to retrieve the db-key value before issuing the FIND/OBTAIN DB-KEY.

The ACCEPT function returns a db-key based on some currency. The following ACCEPT function options indicate which currency to use and what db-key value to return:

Note: Other ACCEPT functions, not discussed here, retrieve run-time statistics and database procedure control areas.

The following figure illustrates the techniques of returning database keys and using them for direct retrieval.

To determine June Moon's expertise rating for C++, we must locate the EXPERTISE record for C++ in her EMP-EXPERTISE set occurrence. This would be easy to do if the skill name were contained as a field in EXPERTISE records; we would CALC to June Moon and walk her EMP-EXPERTISE set examining the skill name in each EXPERTISE record that we accessed. However, to avoid data redundancy, the skill name is not carried in EXPERTISE records, so we will use the ACCEPT function to efficiently accomplish the same thing.

We first determine the db-key of the C++ SKILL occurrence and then walk June Moon's EMP-EXPERTISE set. For each member retrieved, we use the ACCEPT function to retrieve the db-key of the owner in its SKILL-EXPERTISE set and compare the value to that for C++. If they are equal, then we have located June Moon's expertise in C++.