Updating the Data Dictionary |
|
Be aware that all changes made to the definition (table) currently loaded in Data Dictionary Maintenance are written immediately to the providex.ddf and providex.dde files as they are entered.
To embed the current definition into the physical database file, click the Update File tool bar button. Depending on the contents of the current definition, PxPlus will determine how to update the physical file with the current definition:
• If the file does not exist, PxPlus creates it and then embeds the definition.
• If the file contains data and its existing definition (key structure, separator and embedded data dictionary) corresponds with the newly created definition, PxPlus will embed the new definition (without touching the data).
• If the file attributes/data elements have changed in such a way that a data conversion is required, an Update physical window with Update Options will display.
This process can also be achieved programmatically. See Automating the Embedded (Physical) Definition.
To update the physical file after changes are made to the current definition, click the Update File tool bar button. If the changes do not require a data conversion, a message will display to confirm that the dictionary has been updated. If a data conversion is required, the Update physical window with update options will display:
This window consists of the following:
(File Changes) |
(Display Only) Area that describes the file changes. | ||||||
Update Options |
Important Note: | ||||||
Ok |
Performs the selected update option. | ||||||
Cancel |
Closes the Update physical window without updating. |
To update multiple native (PxPlus) files, see Update Physical Files utility.
Create a new definition in the data dictionary (providex.dde and providex.ddf files) by entering a name in the Name field of the Main Panel. If the entered name does not exist, you will be asked to create a new definition. Enter the path of a data source in the Physical File field.
If the data source contains an embedded definition, then Data Dictionary Maintenance can automatically extract the contents of that definition and populate all the corresponding fields with existing information.
This process can also be achieved programmatically. See Automating the Data Dictionary Update.
CALL "*dict/dd_updt;Update_DD", pathname$, newpath$, errmsg$
Where:
pathname$ |
Pathname of the database file containing the source definition. |
newpath$ |
Pathname to be stored in the providex.ddf (if other than pathname$). If this value is null, then pathname$ is assumed. |
errmsg$ |
Error message to be issued if the update procedure aborts. |
The Update_DD routine in PxPlus can be called from an application in order to update the data dictionary files (providex.ddf and providex.dde) using information extracted from an existing embedded definition.
CALL "*dict/dd_updt;Update_Physical",ERR=stmtref,table$,newpath$,flags$,errmsg$,pswd$,level
Where:
stmtref |
Program line number or statement label to which to transfer control. | ||||||||||||||
table$ |
Logical name of the file to be updated. | ||||||||||||||
newpath$ |
Pathname of the file to be updated if other than the one specified in the path field in the providex.ddf; otherwise, this value is null. | ||||||||||||||
Data dictionary flag values:
Any combination of the above can be used (e.g. "DX","SAD","SADB", etc.). (The "V"erbose flag was added in PxPlus 2020.) | |||||||||||||||
errmsg$ |
Error message to be issued if the update procedure aborts. | ||||||||||||||
pswd$ |
Password to be applied to the file. | ||||||||||||||
level |
Access level:
|
The Update_Physical routine can be used to update the embedded definitions using information from the data dictionary files (providex.ddf and providex.dde).
• If the file does not exist, PxPlus creates it and embeds the definition.
• If the file exists but has no data, the file is recreated with the new definition, unless the flag$ variable includes "DX".
• If the file contains data, the new definition is embedded based on flag values, the file is recreated and the records converted to the new format. See Example below.
The Update_Physical routine can be used in the batch conversion of database files from external/legacy formats to the PxPlus data dictionary. See Converting Other Formats.
Example:
The following sample program creates all the files defined in a data dictionary and embeds the individual definitions (tables) into the corresponding files:
! DD_CRPHY - ! Create Physical Files from the Data Dictionary
! This program creates all files in the data dictionary in the current directory
!
print 'CS','blue',"Create Physical Data Files from Dictionary",'RM'
d_flag$="" ! Set flag to create/convert/update
ddf_fn=hfn;
open (ddf_fn,iol=*)"providex.ddf" ! Open DD header file
select * from ddf_fn begin "000001"
ddf_key$=kec(ddf_fn)
if stp(PhysicalPath$)="" \
then print 'SB','magenta',"Warning: "+ddf_key$+"-"+Name$+" has no path. Cannot create.",'RM';
continue ! Check for incomplete record
if mid(tbl(mid(PhysicalPath$,1,1)="=",PhysicalPath$,evs(PhysicalPath$(2))),1,1)="@" \
then continue
! filter out Views
print "Creating ",ddf_key$," - "+Name$,@(50)," >> ",PhysicalPath$
call "*dict/dd_updt;Update_Physical",Name$,"",d_flag$,errmsg$
if stp(errmsg$,2)<>"" \
then print 'red',errmsg$,'RM'
next record
print "File update complete"
close (ddf_fn)
end