DATUPD
The datupd
external program can be used to maintain databases. You can add new records, even on tables that contain keys (for example you can add new drill holes), update existing tables, update existing fields, replace existing records with other records (for example, the original 0-15 interval could become 0-5, 5-10 and 10-15.
Usage:
dataupd <proj> <spec_id> <> indicates a mandatory switch. [ ] indicates an optional switch |
Where:
Option | Description |
---|---|
<proj> |
Refers to the project code. |
<spec_id> |
Refers to the name of the specification file. |
DATUPD Specification File
The specification file is split into three sections:
Environment
This section sets the parameters of the program, i.e. name of input file, check methods, etc.
The items that may be included in the Environment section of the specification are outlined in the table below. You must include the mandatory items.
Item | Optional/Mandatory | Description |
---|---|---|
ENVIRONMENT | Mandatory | This is the environment code. |
PROJECT | Mandatory | This is the project code. |
DATAFILE | Mandatory | This is the name (including extension) of the input data file. |
UNKNOWNFILE | Mandatory | This is the name (including extension) of the file for storing any unmatched records. |
DURATION | Mandatory | This is the number of days a record can be in the Unknownfile before you will be asked whether or not to delete it. If the value is zero, then you will be notified immediately when a record is not matched. |
UNKNOWNFILE_SKIP | Optional | Doesn't check the unknownfile for matches. Normally the program would check the unknownfile for matches and if necessary update the database. |
SELECTION_FILE | Optional | File containing a list of the keys to use. |
DELETE_IMPORT | Optional | Deletes the input file once the data has been imported. |
VERBOSE | Optional | Prints messages while the program is running. Can be useful for debugging purposes. |
UPDATE_RECORDS REPLACE_RECORDS CREATE_RECORDS APPEND_RECORDS |
Optional | This is the task you want to perform, i.e., do you want to update an existing table (record), create a new one, or add extra information to an existing table (record). If you don't include one of these options, then the program will default to UPDATE_RECORDS. |
NUMERIC_CHECK | Optional |
This can be one of 'ONE_TO_ONE' or 'RANGE'. ONE_TO_ONE updates records if the fields match exactly. RANGE is used when you want to replace existing records with other records. For example, Database FROM TO SEAM 0.0 10.0 10.0 20.0 20.0 30.0 B 30.0 40.0 Data file FROM TO SEAM 10.0 30.0 C Database after update FROM TO SEAM 0.0 10.0 10.0 20.0 C 20.0 30.0 C 30.0 40.0 |
NUMERIC_FIELDS | Optional | This can be one of '1' or '2'. This is the number of numeric fields to check. |
DELETE_OLD | Optional | Automatically deletes any records in the Unknownfile that are older than the DURATION. |
**Datupd Spec File**
BEGIN$DEF ENVIRONMENT
ENVIRONMENT='krja'
PROJECT='test'
DATAFILE='header.dat'
UNKNOWNFILE='error.txt'
NUMERIC_FIELDS=1
NUMERIC_CHECK='ONE_TO_ONE'
DURATION='10'
DELETE_OLD
VERBOSE
APPEND_RECORDS
END$DEF ENVIRONMENT
Database
This section defines the database, i.e., the name if the database, table names, field names, field column numbers etc.
This section provides information about the database that you want to update. You must include the mandatory items.
Item | Optional/Mandatory | Description |
---|---|---|
Database Name | Mandatory | This is the name of the target database. |
Database Name | Mandatory | This is the name of the target database. You need to specify the name again as part of specifying the database table (record). |
Table (record) name | Mandatory | This is the name of the table (record) in the database. You can specify more than one table. |
Record Type | Mandatory | This is the record type. The position is defined by the ID_TYPE_TO and ID_TYPE_FROM entries in the data file section. If you only have one type, then leave it blank, i.e., ' ' |
Field Names | Mandatory | Enter the names of the fields. If NUMERIC_CHECK is set, the first fields must be the numeric fields followed by the data fields. |
BEGIN$DEF DATABASE
test.geo <---------- Database Name
END$DEF DATABASE
BEGIN$DEF TEST.GEO <---------- Database Name
BEGIN$TAB HEADER <---------- Table Name
'' <---------- Record Type
'HOLEID' 'DATE' 'AREA'
END$TAB HEADER
END$DEF TEST.GEO
Data File
This section defines the input data file, i.e., the record type, position of fields in the file, etc.
This section provides information about the data file you are going to use to update the database. You must include the mandatory items.
Item | Optional/Mandatory | Description |
---|---|---|
ID_TYPE_FROM and ID_TYPE_TO | Optional | These are the column numbers for the record type. Only specify values if you have more than one record type. |
ID_FIELD_START and ID_FIELD_END | Optional | These are the column numbers for the tag that resides in both the database record and data file and links the two together. This is used to identify insertion records. |
ID_KEY_FROM and ID_KEY_TO | Optional | This is the database grouping key. It is used to speed up the search. If not specified, then every record is checked for compliance. |
RECORD_ | Mandatory | This is the record type identifier. Add the identifier after the _, for example, RECORD_1. If you only have one record type, leave it blank, for example, RECORD_ |
FIELD | Optional | This is the names and positions of the fields in the data file. |
BEGIN$DEF TANK_FORMAT
ID_KEY_FROM=1
ID_KEY_TO=16
BEGIN$TAB RECORD_
'FROM' '18' '25'
'TO' '27' '34'
'LITH' '36' '42'
END$TAB RECORD_
END$DEF TANK_FORMAT
More examples
Figure 1: Adding new drill hole HEADER records to the database
2- Replacing the entire contents of existing HEADER records with new information and adds new HEADER records where necessary
3- Adding new drill hole GEO records to the database
4- Replacing existing GEO records with new information, where necessary old records are removed and replaced with new multiple records
5- Appending additional drill hole GEO records to existing drill holes in the database
Figure 2: Updating existing database fields based on sample numbers
Figure 3: Updating existing database fields based on hole id and depth field