Database Modifications
- Last UpdatedJan 28, 2025
- 3 minute read
The following modifications are allowed:
The Modification Pipeline
When an element is modified, it is not simply the case of directly updating the database. For example, when setting an attribute the following sequence takes place:
-
Check that the attribute value is the right type
-
Check against any valid values or ranges
-
If the new value is the same as before, then return.
-
Check against the user access control defined in the system DB.
-
Check that the DB is open in write
-
Check LOCK flag
-
Do claim check, and claim if needed if DB is 'implicit claim'
-
Make attribute specific checks.
-
Make the actual database change.
-
Add to change list
-
Invoke attribute specific follow up code.
-
Update any dynamic rules affected
It can be seen that making what appears to be a simple modification is actually quite complicated.
In particularly a lot of errors are possible. Errors may be generated by any of the steps 1-2 plus steps 4-8.
If an error occurs the code will raise a PdmsException. The calling code needs to allow for this.
Clarification of some of these errors is as follows:
Check that the attribute value is the right type
For example, if a text attribute then the new value must be text, for example: setting DESC to 99 will raise an error.
Check against any valid values or ranges
This will check the value against any user provided criteria stored in the dictionary DBs.
Check access control
An error will be raised if the modification is not allowed. An error will also be raised at this point if the attribute is not valid for the given element.
Check that the DB is open in write
An error will be raised if 'read only'.
Check LOCK flag
An error will be raised if the LOCK flag is true.
Do claim check, and claim if needed (and implicit claim is allowed)
An error will be raised if:
-
The DB uses explicit claims and the primary element has not been claimed.
-
The primary element is claimed by another user or extract.
Call the legality checking routines to make sure that the modification is valid
These checks are made by the plugged in application specific code. Thus potentially any error could be raised.
Claiming Elements
If a DB has been set up to be 'implicit' the user will claim elements as needed without having to do explicit claims.
There are some methods on DbElement to claim/release individual elements or a hierarchy of elements. If working on a hierarchy of elements, and errors occur, then the system will still do what it can.
There are also methods on the MDB class to claim/release a list of elements. Performance is improved by claiming or releasing elements in bulk, thus in general the MDB methods should be used rather than the ones on DbElement.
The granularity of claim is at the level of primary element. Refer to Claim Elements for further information.
Pseudo Attributes Relating to Claims
|
Attribute Name |
C# Data Type |
Description |
|
CLMID |
String |
Unique system ID of user claiming element |
|
CLMNUM |
int |
User or extract number claiming element. Extract numbers are negative |
|
CLMTIE |
DbElement[] |
Reference to elements that are automatically claimed along with this element |
|
NPDESC |
DbElement[] |
List of non primary offspring |
|
OKCLA |
bool |
True if element may be claimed |
|
OKCLH |
Bool |
True if element and hierarchy may be claimed |
|
OKREL |
bool |
True if element may be released |
|
OKRLH |
Bool |
True if element and hierarchy may be released |
|
PRIMTY |
Bool |
True if element is primary |
|
PRMMEM |
bool |
True if there are any primary elements amongst descendants |
|
PRMOWN |
DbElement |
Primary owning element (will be itself if primary) |
|
USCLHI |
DbElement[] |
Elements in descendant hierarchy claimed to this user |
|
USERC |
String |
User name of user claiming element |
|
USNCLH |
DbElement[] |
Elements in descendant hierarchy not claimed to this user |