Professional Documents
Culture Documents
DataDict V910
DataDict V910
DataDict V910
10
Data Dictionary
Introduction 3
Data Dictionary Maintenance 4
Updating the Data Dictionary 19
Data Dictionary Utilities 25
Using the Data Dictionary 33
Converting Other Formats 34
Data Dictionary Objects 36
SQL Interface Objects 64
Data Classes 76
Password Protection 78
ProvideX is a trademark of Sage Software Canada Ltd.
All other products referred to in this document are trademarks or registered trademarks of their
respective trademark holders.
The capabilities, system requirements and/or compatibility with third-party products described herein
are subject to change without notice. Refer to the Sage ProvideX website www.pvx.com for
current information.
What is it? A data dictionary is a collection of data definitions used by applications to describe
and access a database. These definitions do not contain actual data; rather, they
comprise standardized "bookkeeping" information about the data (metadata). This
includes details on the types, names and structures of all data elements, as well as
their interrelationships within the larger context of the database.
How is it ProvideX includes several facilities for building and accessing a data dictionary. The
Defined? primary method for creating/modifying data definitions is via the Data Dictionary
Maintenance interface in the NOMADS toolset. Equivalent programmatic access is
also available through Data Dictionary Objects. A central repository of data
dictionary definitions is maintained in two ProvideX files:
providex.ddf, defining all the files (or tables) that belong to the database, and
providex.dde, defining specific elements (or columns) that exist within these files.
One important feature about the Providex data dictionary is that the definitions stored
in the repository are also written directly into the corresponding database files.
What is it At the most basic level, a data dictionary is used for Accessing the Data in a
Used For? database. However, the data dictionary has multiple uses in ProvideX, from rapid
application development to the conversion of data.
Embedded IOLists. Because the definitions can be saved to the physical files, a
separate IOList does not have to be written in programs that use the data. ProvideX
accesses the embedded definitions independent of the central data dictionary.
NOMADS. The data dictionary is required for File Maintenance to generate panels
and maintenance programs. It also facilitates the creation of Query definitions.
Views. The ProvideX Views system can employ the data dictionary’s embedded
definitions to generate end-user Views of the data.
ODBC. The data dictionary is fully-compatible with the ProvideX ODBC Driver. The
driver simply reads the embedded IOList to determine the fields and format of the
database file. Otherwise, when the data dictionary is not present, a manually-written
INI file would have to be created for each file in order to access the data.
BMK
As mentioned earlier, NOMADS includes a utility for building and maintaining the
data dictionary. Click Dictionary > Maintenance from the NOMADS menu bar.
Alternately, you can type DD (or DD tablename) at the ProvideX Command prompt.
The basic steps for creating definitions in the data dictionary include: identifying the
database file, defining the elements, defining the keys, and copying the updated
definition to the physical file. The Data Dictionary Maintenance interface presents
all the different options and fields necessary to complete these steps:
For Updating the Data Dictionary and embedding the
Main Panel definition in the physical file. Settings include table name,
key definition, access logic, and notes.
Within the main panel there are two tabbed panels for specifying further details about
the data files and their elements:
Options and fields for describing the physical file,
General File Information
including pathname, group, file type, and block size.
Options and fields for defining all the data elements
Data Elements within the current the definition, as well as for the
global dictionary.
Main Panel
The options and settings listed below are available from the main panel:
Menubar Items
The main panel includes the following drop-down menu items:
File Some of these items also appear as buttons in the main panel:
Change Dictionary Changes the path to a new providex.ddf.
Rename Table Changes table to a new name.
Delete Table Deletes the currently-loaded table.
Notes Provides free-form area for recording notes on the table.
Define Keys Sets up primary and alternate keys for the physical file.
IO Procedures Sets up logic for controlling file access.
Update File Embeds data dictionary into the physical file.
Create SQL Key Defn File. Creates providex.kdf in the same directory as
the providex.ddf and providex.dde files. This
file contains SQL key definitions for a providex data
dictionary table, keyed by the logical table name (64
characters). If the KDF file exists, the user is prompted
to delete and re-create the file.
Exit Exits the Data Dictionary Maintenance interface.
Edit This drop-down is enabled when used with the Data Elements tab:
Add Element Inserts a data dictionary element.
Delete Element Deletes a data dictionary element.
Add Globally Adds the selected element to the Global Dictionary.
Options Provides additonal data dictionary options:
SQL Key Definition Update Determines whether the SQL Key Definition
file will automatically be updated when the ProvideX
Data Dictionary key definition is changed. See SQL
Key Definition Update Options, p.23.
Utilities Provides additional data dictionary tools and security control. The
following are fully documented under Data Dictionary Utilities, p.25:
Print Opens Print Data Dictionary Definition panel.
Compare Definitions Opens Data Dictionary Compare panel.
Generate External Sub-menu for accessing:
INI file contents
SQL Create Table
Key Definitions
Import Dictionary Opens the Copy Data Dictionary Definition panel.
Table Name Descriptive name for your data source (maximum 64 characters)
used to identify its definition in the data dictionary; e.g.,
Customer. Existing tables can also be viewed via:
Tree view of table names by Group
Query view of tables by table name
Advance table name based on current view.
See also, Creating a Definition, p.20
Notes Provides a free-form area for recording notes on the table and its
use. (maximum 1024 characters).
SQL Keydef Creates/removes SQL key definition for selected table. Button is
hidden if providex.kdf does not exist. To create the KDF file,
select File>Create SQL Key Defn File from the menubar. SQL Key
Definition, p.24.
Define Keys Button gives you the option to set up primary and alternate
keys for the physical file. See Defining Keys, p.16.
IO Procedures Button displays a window where you can enter the name of a
program that contains logic for controlling file access.
Update File Button for embedding data dictionary into the physical file.
Data Elements
The second tab in the Data Dictionary Maintenance interface provides various
options and settings for defining elements in the physical files.
Data Elements... Lists all of the data elements for the current table. Double-click
on an element to access Element Description settings.
Inserts or deletes a data dictionary element. See Element
Description, p.9.
Moves the currently-selected data dictionary element up or
down a position in the list.
Adds or moves the currently-selected element from the Data
Elements list to the Global Dictionary list, or vice versa.
Global Dictionary... Lists global elements – elements that are common in several
files. When an element is defined globally, you will be able to
select and load its definition into various file definitions using
the right side of the Data Elements sub-panel in the Data
Dictionary Maintenance interface.
Global dictionary element definitions are stored in the data
dictionary files, providex.ddf and providex.dde and can
be accessed and modified by selecting {Global Dictionary}
from the list of logical file names in the Table Name field.
Non-Normalized Checkbox allows the definition of non-normalized data files.
See Non-Normalized Data, p.15.
Record Format: Record type description for non-normalized data files.
Note: Some of the above settings as well as some data dictionary utilities can be
invoked via drop-down menus in the Data Dictionary Maintenance menu bar.
Element Description
This sub-panel under Data Elements is used to supply details about the
currently-selected element. It is divided into four tabbed folders for defining the
Display, User Aids, Query and ODBC attributes for each element in the data file.
Name: Unique name of the element – this is the variable name used in the
primary IOList. Naming conventions for variables apply.
It is possible to restrict element names. To exclude names, such as
SQL keywords, create a list of rejected names (one item per line) in
the text file dde_exclude.txt located in the *ext directory; i.e.,
PathToProvidex/lib/_ext/dde_exclude.txt. If you choose
your own file/location for this list, the path must be loaded into
the %DDE_Exclude$ variable. When this file is present, new
names will be checked against the restricted list and rejected if
found. No action is taken for elements that already exist. Text in
this file is treated as case-insensitive and spaces are stripped.
Alternate Name: Alternate name for use in the alternate IOList (for legacy
programs). If an alternate IOList is defined, then you must define
an alternate name for all elements in the file. The alternate name
must be a variable name (e.g., A$ or A$[1]). Supports only
Fields that use the Delimited format mask.
Class: Associated data class for pre-loading information (e.g., type, size,
description, input methodology, default values, etc.). Class can
also be used to associate a control type (multi-line, drop box, list
box, check box or radio button) with the element for use within
NOMADS subsystems. See Data Classes, p.76.
External only Checkbox indicating that the element forms part of an external
key and is not duplicated in the data portion of the record. For
example, Key: CST_ID$ Data: CST_NM$, CST_ADDR$,
CST_PHONE$. In this case, CST_ID$ forms the key and is not
duplicated in the data portion of the record.
Required Checkbox indicating that the element is a required field and must
contain data before the record can be written in File Maintenance.
UpperCase Checkbox indicating that the data should always be in upper
case letters. Used by NOMADS subsystems.
Display
Short Description Brief description of the element, which can be a Fixed value,
Expression or Message Library Reference.
Type: Field indicates whether the element is Numeric or String.
Format Mask: Options define the format for writing the data field to the file; i.e.,
Delimited Delimited by field separator. Sample IOL format: DELIMITED$,
NUMERIC_DLM
Padded Padded with spaces based on the defined length. Numerics are
padded with leading zeros. Sample IOL format:
PADDED$:[LEN(6)], NUM_PADDED:[NUM(7)]
Fixed Padded to the specified length when written, but stripped of
trailing spaces when read. Sample IOL format:
FIXED$:[CHR(7)], NUM_FIXED:[NUM(7)]
Substring Similar to fixed, but if the stored data is shorter than the specified
length, a READ will return up to but not including the field
separator. (Used in conjunction with Last Substring. This format
is often used for flag fields. Sample IOL format:
SUBSTRING$:[LEN(5,SEP=SEP)]
Padded Key Field padded with spaces based on the defined length.
Fixed Key Field padded to the specified length, unless it is the last key
component. For redundant external key fields (i.e., fields that
form both external key as well as part of data portion of record)
define the format as it should be defined for the data portion.
User Aids
Help Reference Help text to be launched when the user presses Shift - F1 .
Choose from one of two drop list items to access form fields for
specifying the different definitions (either External or Internal).
External Standard (default) help definition. This assigns a predefined
help file that can be Fixed text (string literal) or an Expression
(or string variable). Specify the starting point in the help file by
Reference or by Keyword. The Popup check box allows you to
set the display to be a pop-up rather than independent window.
Internal Simplified help stored in the library file. This help consists of
text only, either Fixed, Expression, or Message Library
Reference. Because the help text is preserved in the library
itself, it eliminates the need to create separate help files.
Notes..... Detailed description of the element for documentation purposes
only. (maximum 240 characters)
Query
ODBC
Non-Normalized Data
If Non-Normalized is checked off in the Data Elements panel, then you will be able
to define the records in a non-normalized data file.
Support for this capability is provided only within the Data Dictionary
Maintenance interface, not within ProvideX or NOMADS subsystems. This option
is intended primarily for the creation of INI files and SQL database definitions when
migrating applications. See also, Supported File Types, p.4.
Defining Keys
Click the button in the Main Panel to set up primary and alternate
keys for the physical file. As mentioned earlier, a key is a string of characters used to
identify the records in a file.
Primary Key
If a primary key hasn’t yet been defined, you will be given the option to set one up.
Select the Data Fields and the sort order that make up the primary key. Key
segments can be composed of one or more strings or substrings.
Select External, if the key is external, otherwise the key will be considered internal.
An external key can be made up of segments and can include a mixture of
external-only and duplicated elements.
The Unique option is checked by default. Fields and settings for defining primary
and alternate keys are fully described in the section Key Definition Panel, p.17.
Alternate Key
Once a primary key is defined, you will be able to include up to 15 alternate keys
with a total of 96 segments (FLR/VLR). EFF files can have a maximum of 255 keys
and 255 segments per key.
Data Fields Lists defined Data Elements for the selected file. You can select
these to construct key.
Key Segments Lists of all the data elements which currently make up the key.
Add Ascending Inserts the selected element from the Data Fields list into the Key
Segments list. Sort order for this portion of the key is ascending.
Add Descending Inserts the selected element from the Data Fields list into the Key
Segments list. Sort order for this portion of the key is descending.
Add Binary Auto Defines binary auto increment for the key, record- based, by the
Increment record offset (base 1) and length (1,2, or 4 bytes). Segments may be
designated as swapped (same as SWP( ) type 7, Intel x86 type
swapping only).
Segment Options Sets different segment options for the selected segment.
Embedding a Definition
To embed the current definition into the physical database file, click the
button. Depending on the contents of the current definition, ProvideX will determine
how to update the physical file with the current definition.
• If the file doesn't exist, ProvideX 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,
ProvideX 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, you will be presented with update options. Refer to the
illustration on the following page.
Convert existing data Update the file using the changes outlined in the area above.
You will be prompted with a message to make a backup of
your existing file before ProvideX overwrites it.
Clear existing data Purge data in the existing file.
Rewrite data Update the embedded definition using the changes outlined
dictionary only in the area above, but without touching the data. This does not
change the actual keys or records inside the file.
Important: To avoid loss of data, it is best to use the Rewrite data dictionary option when
embedding a definition for the first time. Only Convert existing data once the physical
file has been tested to ensure the new definition matches the contents exactly.
Creating a Definition
Create a new definition in the data dictionary (.dde and .ddf files) by entering a
name in the Table Name field of the Main Panel. If the entered name does not exist,
you will be given the option 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 the Data Dictionary
Maintenance interface 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, p.21.
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 doesn't exist, ProvideX creates it and embeds the definition.
• If the file exists but has no data, the file is recreated with the new definition.
• 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. Refer to the example below.
The Update_Physical routine can be used in the batch conversion of database files
from external/legacy formats to the ProvideX data dictionary. For more information,
see Converting Other Formats, p.34.
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
Options The following options are accessed via the Options dropdown on the Data
Dictionary Maintenance menubar.
The Delete button will be disabled if the record does not exist in the providex.kdf
file.
BMK
Access to additional data dictionary tools and security control is available via the
drop-down menu in the Data Dictionary Maintenance interface:
Drop-Down Menu
The following drop-down menu items are described below: Print, Compare
Definitions, INI File Generation, SQL Create Table, Merge, and Import
Dictionary, Key Definitions.
Print
The Print Data Dictionary Definition panel is accessed using the Print link in the
Utilities Drop-Down Menu. This allows you to generate output in a standard format
that lists all of the elements in the definitions that have been selected for printing.
Available Tables Lists definitions (tables) in the current data dictionary that are
available for printing.
Selected Tables List the tables that have been selected for printing. Use the Select
All, Include, and Remove buttons to add/remove selected items.
Print Option Checkboxes provide the choice between a Detailed Report or a
Summary Report.
Automated Call
The Compare utility can also be called from a ProvideX program.
CALL "*dict/compdict;ANALYZE",source1$,table1$,source2$,table2$,result$,suppress$
Where:
source1$ Full path of the ProvideX.ddf or physical file with embedded
dictionary that you want to compare from.
table1$ Table you wish to compare from. Leave blank to indicate all.
source2$ Path name of the ProvideX.ddf or physical file with embedded
dictionary that you want to compare against. Enter * to use the physical
files associated with the tables from Source 1.
table2$ Table you wish to compare against. Leave blank to indicate all.
result$ A SEP-delimited string containing "what is being compared"+ SEP
+"source1 result"+ SEP + "source2 result"
suppress$ The flag "1" will suppress details on new/deleted files.
When generating the contents for an INI file from a table with multiple record
formats, the system will generate a logical table name consisting of the table name,
an underscore, and the record name. All spaces within table names will be converted
to underscores. The contents of the INI file are output to the screen for viewing
purposes, with additional options to output to a file or the clipboard.
Automated Call
The INI File Generation utility can also be called from a ProvideX program.
CALL "*dict/defini",contents$, errmsg$, tablename$, ddf_path$
Where:
contents$ INI file contents are returned in this variable.
errmsg$ Warning and error messages are returned in this variable.
tablename$ Logical table name
ddf_path$ Pathname of the providex.ddf file (defaults to simple pathname)
The utility outputs CREATE TABLE directives for defining database tables that are
consistent with the ProvideX data dictionary. By default, this output includes all the
fields within a table definition, including fields in non-normalized tables.
In the case of non-normalized files, duplicate element names are output once, and
the first occurrence of the element name defines the element's format. Table Index
definitions will also be created using either the Key name as supplied in the Data
Dictionary definition or a generated name based on the Table name followed by an
underscore and key number. The CREATE statements are output to the screen for
viewing purposes, with additional options to output to a file or to the clipboard.
Automated Call
The SQL Create Table utility can also be called from a ProvideX program.
CALL "*DICT/GENSQL",contents$, errmsg$, tablename$, ddf_path$, quo_char$
Where:
contents$ SQL CREATE commands are returned in this variable.
errmsg$ Warning and error messages are returned in this variable.
tablename$ Logical table name
ddf_path$ Pathname of the providex.ddf file (defaults to simple pathname)
quo_char$ Character to enclose tables, columns, indexes names (defaults to null)
Merge The Data Dictionary Merge panel is accessed using the Merge link in the Utilities
Drop-Down Menu.
This utility allows table definitions to be merged from one set of dictionary files
(ddf/dde) to another. Processing a merge involves defining a merge option to deal
with cases where the table being merged already exists in the destination dictionary
files. You can select an option to replace the contents of the table definition in the
destination file, merge the contents of the source and destination files (with the
source definition taking precedence), or skip the table.
The left side of the panel lists the dictionary tables displayed by file groupings in a
tree view format. Clicking on a particular table will cycle through the options for
dealing with duplicate tables. Clicking on a file group will cascade the setting for the
group to its associated tables, and clicking on the source path at the top of the tree
will select for the entire tree. The panel on the right displays the element descriptions
and indexes for a selected table. A description of option symbols appears in the
Legend popup, which can be invoked by clicking .
Preview Button
Press to display a report view list box showing the pending result of
merging a table highlighted in the tree view, using the specified merge option.
In the following example the Merged result would show the addition of a dictionary
element Custom and a new key #4)Custom+CST_ID.
Merge Button
Press to initiate the merge logic. During a merge, the status bar at the
bottom of the panel will be updated with the name of the table being processed.
Merge processing will be accomplished using the Merge( ) method, of the object
described later.
Automated Call
The Merge utility can also be called from a ProvideX program.
CALL "*dict/merge;MERGE_TABLES",SrcDDF$,SrcTable$,DestDDF$,MergeOpt$
or
CALL "*dict/merge;MERGE",SrcChan,SrcTable$,DestChan,MergeOpt$
Where:
SrcDDF$ Path to the dictionary source file (providex.ddf).
SrcChan Open channel to the dictionary source file (.ddf).
SrcTable$ Name of the table to be merged from the source dictionary. If
omitted, then all tables are merged.
Import Dictionary
The Copy Data Dictionary Definition panel is accessed using the Import Dictionary
link in the Utilities Drop-Down Menu.
This utility is used to copy a file definition from a different ProvideX data dictionary (in
another directory) into the current file definition. If a file named in Physical File has an
embedded data dictionary, then the definition can be loaded automatically; however,
definitions from other data dictionary (ddf/dde) file sets must be imported using this utility.
Note: This utility is used for importing ProvideX data dictionaries only. For converting
formats from outside of ProvideX, refer to Converting Other Formats, p.34.
To import a definition, enter a new or existing Table Name in the Main Panel of the
Data Dictionary Maintenance interface, then select the definition to be copied.
Copy To: Table that the definition will be copied into. This is the Table
Name from the main Data Dictionary Maintenance panel.
Copy From: Directory where the data dictionary (ddf/dde) file sets reside.
Press to select a different directory.
Dictionary: List of file definitions residing in the Copy From directory. Select a
definition and press to import into your target file.
Key Definitions
The Generate External Database Key Definitions panel is accessed using the
Generate External link in the Utilities Drop-Down Menu. This utility generates SQL
key definitions for data dictionary tables.
The key definitions are stored in a new providex file providex.kdf. The file is
keyed by the logical table name (64 characters) and is created in the same directory
as the providex.ddf and providex.dde files.
Once a Dictionary Source has been selected, the table names (sorted by the data
dictionary group name) are displayed in a tree view control with the dictionary
source name displayed on the top branch.
To select/de-select a table, click on the check box icon beside the table name. If you
wish to select/de-select all tables for the dictionary source, click on the check box
icon beside the dictionary source name in the tree view.
BMK
As described in the Introduction, the ProvideX data dictionary can be used for
designing database applications, and is employed in different ways by ProvideX
facilities, such as the Views system, the ODBC Driver, and NOMADS.
However, the primary purpose of the data dictionary is to document the contents of
a database so that it can be easily viewed, queried, and accessed by an application.
The following ProvideX syntax uses the embedded definition to perform these tasks.
Example The following program illustrates how to open a file and read its contents using an
embedded definition. It uses demo files that were installed with ProvideX. You must
be in the path /lib/NOMADS/ for this to work.
00020 BEGIN
00030 OPEN (1,IOL=*)"cstfile" ! Open with data dictionary access
00040 PRINT "Load regular IOLIST ___________________"
00050 READ (1,END=0080) ! No reference to IOL required
00060 GOSUB PRINT_RECORD
00070 GOTO 0050
00080 CLOSE (1)
00160 END
00170 PRINT_RECORD:
00180 PRINT "___"+KEC(1)+"___"
00190 PRINT "Standard iolist"
00200 PRINT "CST_ID$=",CST_ID$
00210 PRINT "CST_NAME$=",CST_NAME$
00220 PRINT "CST_ADDR$=",CST_ADDR$
00230 RETURN
BMK
Data conversion can be one of the most lengthy and difficult procedures involved in
the migration of any database. While there are tools available for importing the
different applications and files into ProvideX, there are no generic utilities for
converting the formatted data to the ProvideX data dictionary. Each external/legacy
database system requires a unique transfer strategy for converting and verifying the
integrity of its data.
This section describes the procedures for mapping the old format to a new ProvideX
data dictionary, and then for embedding the newly-created definitions into their
corresponding data files.
providex.dde
IOLOBJ$ IOList name; e.g., CST_NM$ or CST_ID$:[CHR(6)] or
PRODUCT$:[LEN(SEP,SIZ=20)]. IOList representation of
the element, must correspond to FORMAT$.
Element fields are described under Data Elements, p.8.
Name$ Element name.
Type$ Element type (Numeric or String).
Length$ Element data length.
Format$ Format of data in file (Delimited, Fixed, Padded,
Substring, Last Substring, etc.).
KeyDefinition$ Key definition (keynum:segment:direction:length:offset) if
applicable. The format appears as follows:
keynum - primary (1) or alternate (2, 3, etc.)
seg - segment position (1, 2, 3, etc.)
direction - A (ascending) or D (descending)
length:offset - partial field (substring) start position and offset.
For more information, see Defining Keys, p.16.
The following sample table was cropped from the data dictionary layout:
BMK
ProvideX includes a set of pre-defined data dictionary objects for working with the
data dictionary. These objects, which are designed for use under ProvideX Object
Oriented Programming (OOP), are described in the sections that follow.
Maintenance Objects
The DataBase and PVXDb objects allow you to create and modify the ProvideX data
dictionary at both the logical (providex.ddf and providex.dde) and physical
file level. Basically, these provide the same functionality programmatically that is
available via the Data Dictionary Maintenance interface:
DataBase Accesses providex.ddf and providex.dde files, returning table,
column and index information for the specified table name (table).
PVXDb Accesses internal definitions that are embedded in a file using a file
handle (fh) to reference each PVX data file.
Methods belonging to these objects are listed and described in the section DataBase
and PVXDb Objects, p.37. These, in turn, delegate functionality to a level of
Subordinate Maintenance Objects, p.43. For sample programs refer to
Maintenance Examples, p.52.
Information about this object is provided under Db_Manager Object, p.62. For
sample programs refer to Database Interface Examples, p.63.
Creating/Updating Files
The following table lists and describes the methods used for creating, deleting, and
importing data dictionary files.
Accessing Information
These methods access information related to a data dictionary definition (table). The
first parameter (fh in examples below) can be a string (table name) or a number
(channel number). A table name indicates that the data dictionary files will be read;
otherwise, the channel number will be used for querying the physical table.
Updating Definitions/Tables
These methods will update the data dictionary definition. The first parameter (fh in
examples below) can be a string (table name) or a number (channel number). A table
name indicates that the data dictionary files will be read; otherwise, the channel
number will be used for querying the physical table. When updating the data
dictionary you will need to issue an AdjustTable( ) to make the changes on to the
physical tables. When updating physical tables you may want to issue a
ImportTable( ) to have the change reflected into the data dictionary.
Idxinfo
The purpose of this object is to provide a common means to describe the indexes for
a definition (table) or file.
Colinfo
The purpose of this object is to provide a common definition of a data element and to
provide for common data validation rules
Tblinfo
The purpose of this object is to provide information about the file.
Variantinfo
The purpose of this object is to provide a common means to update or change
non-normalized record information for a definition (table) or file.
Maintenance Examples
These sample programs illustrate the functionality of the DataBase and PVXDb
Objects, p.37. Examples include Creating a New Data Dictionary, p.52 and
Embedding a Definition, p.58.
end_IF
! Check Result
if r=0 then \
msgbox "Unable to create index segment"; \
exit \
end_IF
! Set the Key Segment by Getting the DataBase Column Name of Column
number 1
i'columnName$=db'GetColumnName$(t'Name$,1)
i'ColumnAttr$="A"
!
! Add Index to Table
r=db'AddIndex(t'Name$,i)
! Check Result
if r=0 then \
msgbox "Unable to add index"; \
exit \
end_IF
Drop object i
!
! Create a Index Object
i=new("*dict/idxinfo")
!
! Check Result
if i=0 then \
msgbox "Unable to create index object"; \
exit \
end_IF
!
! Show all the Propeties and Methods Available
print 'cs'
print i'*
!
! Set Properties
i'Name$="ByClientThenOrderNumber"
i'IsUnique=1
r=i'AddSegment()
! Check Result
if r=0 then \
msgbox "Unable to create index segment"; \
exit \
end_IF
! Set the Key Segment by Getting the DataBase Column Name of Column
number 1
i'columnName$=db'GetColumnName$(t'Name$,2)
i'ColumnAttr$="A"
!
r=i'AddSegment()
! Check Result
if r=0 then \
msgbox "Unable to create index segment"; \
exit \
end_IF
! Set the Key Segment by Getting the DataBase Column Name of Column
number 1
i'columnName$=db'GetColumnName$(t'Name$,1)
i'ColumnAttr$="A"
! Add Index to Table
r=db'AddIndex(t'Name$,i)
! Check Result
if r=0 then \
msgbox "Unable to add index"; \
exit \
end_IF
Drop object i
!
!Lets Create the Physical File
r=db'CreateTable(t'Name$)
! Check Result
if r=0 then \
msgbox "Unable to create Physical File"; \
exit \
end_IF
!
!Drop the DataBase Object
Drop object db
Drop object t
Drop object c
!
open (1,iol=*)"ordh"
number$=dim(19,"0")+"1"
ClientId$="MAS90"
Amount=123.12
Write (1)
number$=dim(19,"0")+"2"
ClientId$="BEST"
Amount=43.05
Write (1)
number$=dim(19,"0")+"3"
ClientId$="PVX"
Amount=567.45
Write (1)
close (1)
!
print 'cs'
open (1,iol=*)"ordh"
print "Iolist of ordh: "+lst(iol(1))
print "List of Key Names: "+fin(1,"key_names")
print "List of Records by Key 0"
Read Record (1)r$
Print R$
Read Record (1)r$
Print R$
Read Record (1)r$
Print R$
!
close (1)
print "List of Records by Key 1"
open (1,iol=*)"ordh"
Read Record (1,kno=1)r$
Print R$
Read Record (1,kno=1)r$
Print R$
Read Record (1,kno=1)r$
Print R$
!
! Create A DataBase Object
db=new("*dict\database")
!
! Check Result
if db=0 then \
msgbox "Unable to create database object"; \
exit \
end_IF
!
! Set the DataBase files to use (ProvideX.ddf ProvideX.dde)
r=db'SetDataBase("c:\MyData")
! Check Result
if r=0 then \
msgbox "Unable to set database"; \
exit \
end_IF
!
! GetTableCount
print "Number of tables found in this ProvideX Data Dictionary are
",db'gettableCount()
print "Number of columns in table '",db'gettablename$(1),"' are
",db'getcolumncount(db'gettablename$(1))
print "These columns are: ",db'getcolumnlist$(db'gettablename$(1),",")
! Create a column object comprised of the information found in Table
Order Header column 2
c=db'getcolumninfo(db'gettablename$(1),2)
print "Column '",c'name$,"' length=",c'length,"
description=",c'description$
print ""
print "Number of indexes in table '",db'gettablename$(1),"' is
",db'getindexcount(db'gettablename$(1))
print "The names of these indexes are
",db'getIndexlist$(db'gettablename$(1),",")
! Create a index object compreised of the information found in Table
Order Header index 2
i=db'getindexinfo(db'gettablename$(1),2)
print "Index '"+i'name$+"' has ",i'segcount," segments"
i'segment(1)
print "Segment 1 is made up of column "+i'columnname$
i'segment(2)
print "Segment 2 is made up of column "+i'columnname$
drop object db
end
Embedding a Definition
This program uses the pvxdb object to manipulate the embedded data dictionary
definition and update the provideX.ddf and provideX.dde with new information.
! Set My Work Directory
cwdir "c:\MyData"
! Create A Pvxdb Object
db=new("*dict\pvxdb")
!
! Check Result
if db=0 then \
msgbox "Unable to create pvxdb object"; \
exit \
end_IF
!
! Show all the Propeties and Methods Available
print 'cs'
print db'*
!
! Set the Physical file to use (ProvideX.ddf ProvideX.dde)
ph=db'open("ordh")
! Check Result
if ph=0 then \
msgbox "Unable to set database"; \
exit \
end_IF
!
! Create a Column Object
c=new("*dict/colinfo")
!
! Check Result
if c=0 then \
msgbox "Unable to create column object"; \
exit \
end_IF
!
! Show all the Propeties and Methods Available
print 'cs'
print c'*
!
! Set Properties
c'Initvalues()
c'Name$="OrderDate"
c'Description$="Order Date"
c'Type$="S"
c'Length=8
c'InternalFormat$="D"
!
! Add Column to Table
r=db'AddColumn(ph,c)
! Check Result
if r=0 then \
msgbox "Unable to add column"; \
exit \
end_IF
!
!
! Create a Index Object
i=new("*dict/idxinfo")
!
! Check Result
if i=0 then \
msgbox "Unable to create index object"; \
exit \
end_IF
!
! Show all the Propeties and Methods Available
print 'cs'
print i'*
!
! Set Properties
i'Name$="ByOrderDate"
i'IsUnique=1
r=i'AddSegment()
! Check Result
if r=0 then \
msgbox "Unable to create index segment"; \
exit \
end_IF
! Set the Key Segment by Getting the DataBase Column Name of Column
number 1
i'columnName$=db'GetColumnName$(ph,4)
i'ColumnAttr$="A"
!
r=i'AddSegment()
! Check Result
if r=0 then \
msgbox "Unable to create index segment"; \
exit \
end_IF
! Set the Key Segment by Getting the DataBase Column Name of Column
number 1
i'columnName$=db'GetColumnName$(ph,1)
i'ColumnAttr$="A"
! Add Index to Table
r=db'AddIndex(ph,i)
! Check Result
if r=0 then \
Db_Manager Object
This object provides a database-independent interface for retrieving and updating
table information. Each method includes an argument to identify the source (or
destination) database. The value of this argument can be specified using the
following code:
dbConstants=new("*dict/db_constants")
tag$="ado"
aDatabaseID=dbConstants'getDatabaseID(tag$)
The database tag$ may be one of the following:
ado Microsoft SQL-Server interface (ADO)
db2 IBM DB2 interface (DB2)
oci Oracle interface (OCI)
odb ODBC interface
mysql MYSQL interface (MYSQL)
pvxddf ProvideX DDF/DDE Files
pvxdb ProvideX embedded Data Dictionary information from a physical file
Different parameter values are used for these methods depending on the source or
destination database. For complete details, please refer to the ProvideX Class
Documentation on the ProvideX website:
http://www.pvx.com/support/#support-docs-pvxclasses.
Sample programs are provided under Database Interface Examples (below).
Example 1
Retrieving the table definition from a Microsoft SQL-Server database (ADO):
db=new("*dict/db_manager")
dbConstants=new("*dict/db_constants")
Table$="Customer"
ConnectOpt$="user=sa;pswd=admin;db=test"
DSN$="ws2003-x86-pdb.pvx.com"
TableOk=db'ReadDefn(dbConstants'getDatabaseID("ado"),Table$,ConnectOpt$,DSN$)
Removing/creating a new table definition in providex.ddf / providex.dde files:
Ddfpath$="c:\pvx\demo\data"
FilePath$="cstfile"
UpdateTable=0
GroupName$="Customers"
Db'droptable(dbConstants'getDatabaseID("pvxddf"),Table$,ddfpath$) ! remove
table definition if it exists
Db'CreateTable(dbConstants'getDatabaseID("pvxddf"),ddfpath$,FilePath$,UpdateT
able,GroupName$)
Updating the table in the ddf/dde files:
Ddfpath$="c:\pvx\demo\data"
FilePath$=""
UpdateTable=1
GroupName$=""
db'CreateTable(dbConstants'getDatabaseID("pvxddf"),ddfpath$,FilePath$,UpdateT
able,GroupName$)
Example 2
Retrieving the table definition from the providex.ddf / providex.dde files:
Db=new("*dict/db_manager")
dbConstants=new("*dict/db_constants")
Table$="Customer"
Ddfpath$="c:\pvx\demo\data"
TableOk=db'ReadDefn(dbConstants'getDatabaseID("pvxddf"),Table$,Ddfpath$)
BMK
ProvideX also includes a set of OOP objects that are designed for accessing and updating
external SQL databases in much the same way as ProvideX Data Dictionary Objects,
p.36. The following support external database interfaces in ProvideX:
db_ado Interface for connecting to a Microsoft SQL-Server database.
db_db2 Interface for connecting to an IBM DB2 database.
db_oci Interface for connecting to an Oracle database.
db_odb Interface for generic open database connectivity.
db_mysql Interface for connecting to a MYSQL database.
Some of these objects replace older versions (described under Legacy SQL Objects).
For complete documentation on the methods and properties that comprise these
objects, refer to the ProvideX Class Documentation on the ProvideX website:
http://www.pvx.com/support/#support-docs-pvxclasses.
The methods and properties from the legacy objects remain compatible with the new
objects. These are described in the sections that follow.
Note: The new objects also contain several methods and properties (for additional
functionality) that are not listed in the tables below. All of the new material is fully
documented under ProvideX Class Documentation on the ProvideX website:
http://www.pvx.com/support/#support-docs-pvxclasses.
Methods are organized according to functionality: Connectivity, Table Operations,
Column Operations, and Index Operations. For descriptions of subordinates to the
primary SQL database objects, refer to the section Subordinate SQL Objects, p.69.
Properties Description
ConnectOption$ Current connect options.(Read-Only); e.g.,
print sql’Connectoption$
USER=guest;PSWD=******
LastMethodErrMsg$ Contains reason why last executed method
failed.(Read-Only)
LastSqlStatment$ Contains last SQL statement that caused the
method to fail.(Read-Only)
LastOsErrorMsg$ Contains PVX MSG(-1) of the last error.
(Read-Only)
LastPvxErr Contains last encountered PVX
error.(Read-Only)
Idxinfo
The purpose of this object is to provide a common means for describing indexes in a
table or file.
Colinfo
The purpose of this object is to provide a common definition of a data element and to
provide for common data validation rules.
Tblinfo
The purpose of this object is to provide information about the file.
Sample Program
This sample program illustrates the functionality of the SQL objects (properties and
methods) that were listed and described in the previous sections. It uses the odbsql
object to display information about the data base and read records from the orders
table found in a Microsoft Access data base.
! Create A Sql ODBC Data Base Object
s=new("*dict\odbsql")
!
! Check Result
if s=0 then \
msgbox "Unable to create sql object"; \
exit \
end_IF
!
! Show all the Propeties and Methods Avialable
print 'cs'
print s'*
!
! Connect to a Microsoft Access DataBase which is called Access and I
would like to be connect to table Orders
ph=s'Connect("Access;Orders")
! Check Result
if ph=0 then \
msgbox "PVX error: "+str(s'lastpvxerr) + sep + "OS Error Message:
"+s'oserrormsg$ ;\
exit \
end_IF
!
!Show Tables all tables in Access Data Base
! GetTableCount
tb$="Orders"
print sep+sep
print "Total number of tables : ",s'gettableCount()
print "Table List : ",s'gettablelist$(",")
print "Table 'Orders' has ",s'getcolumncount(tb$)," columns"
print "Column list : ",s'getcolumnlist$(tb$,",")
! Create a column object compreised of the information found in Table
Order Header column 2
c=s'getcolumninfo(tb$,2)
print "Column '",c'name$,"' length=",c'length,"
description=",c'description$
print ""
print "Number of indexes in table '",tb$,"' is ",s'getindexcount(tb$)
print "The names of these indexes are ",s'getIndexlist$(tb$,",")
! Create a index object comprised of the information found in Table Order
Header index 2
i=s'getindexinfo(tb$,2)
print "Index '"+i'name$+"' has ",i'segcount," segments"
i'segment(1)
for t=1 to i'segno
Data Classes
Dat Clas es
BMK
Data classes are used to implement standardized definitions for commonly used
elements, such as dates, monetary amounts, etc. In other words, you can build a data
class according to a standard and then simply use the generic class as a basis for any
new data element. Use the Data Classifications interface (via NOMADS) to create and
modify data class definitions.
Class Name Key to the providex.dcl data classification file. When you
assign a new data class name, you can use the characters A-Z, 0-9,
the underscore or a period. Blanks are not allowed. Maximum
length 30 characters.
Query view of existing data classes
Advance through available class names.
Description Generic description of the data class (Fixed value, Expression or
Message Library Reference). This will be copied to the data
dictionary when the data class is used in an Element Description.
Control Type Default control type used to represent the data that belongs to your
defined data class (primarily for the NOMADS Panel Designer
and File Maintenance). Choose from the following control types:
Input Field, Drop Box, List Box, Radio Button, Check Box.
This tells the File Maintenance generator which type of control
is to be used for representing the data element. It defaults to an
Input Field (multi-line). By default, any elements defined in the
data dictionary will be represented as a multi-line in the
generated file maintenance panel.
If the Internal Data Type is for a String variable, the value in the
Size field will define the maximum string length. For a Numeric
variable, enter nnn.dd where nnn is the maximum number of
digits (including decimal) and dd is the number of digits after
the decimal point (i.e., the PRECISION). For radio buttons and
check boxes, the size is 1.
Internal Data Type Internal format of the data when manipulated by a program, either
String or Numeric.
Size: Maximum size of stored data element. For string variables, this is the
maximum string length. For numeric variables, enter nnn.dd where
nnn is the maximum number of digits (including decimal) and dd is
the number of digits after the decimal point (i.e., PRECISION of
number). For radio buttons and check boxes, the size = 1.
Popup Menu: Assigns popup menu to a data class (Fixed value or expression, to
be evaluated at runtime when the popup signal occurs). A check
mark indicates that a popup menu is currently assigned to the data
class. This button invokes a panel for assigning Prior Popup logic,
a predefined popup object or user-defined program.
The options available in the Display, Attributes, Values/Validation and Query tabs
varies dependent on the Control Type selected. Most of these options are used by the
NOMADS Panel Designer and File Maintenance to set up controls, and are covered
in more detail in the NOMADS Manual under Dictionary-Based Development.
As pertains to the Data Dictionary, the following fields are used.
Tab
Control Type
Display Attributes Values/Validation Query
Input Field Initial value User tag field Rules Lib/Panel,
(MULTI_LINE) Input format program, or
spinner.
DROP_BOX Not used User tag field Default Setting Lib/Panel, or
LIST_BOX program.
RADIO_BUTTON Default Value User tag field N/A N/A
CHECK_BOX N/A User tag field Default Setting N/A
Password Protection
Pas wordProtection
BMK
This interactive utility allows you to add, change or remove passwords in ProvideX
data dictionary files:
The Data File Password Utility panel, fields and options are described in the pages
that follow.
Table Name Selected table name. If the file is already passworded, then a
password entry dialogue box would be displayed; e.g.,
*cmd/system/get_pswd. If the password entered is invalid,
the Data File Password Utility will exit automatically.
Remove password
Check box for removing an existing password on a file.
from table
New Password New password to be applied to the file.
Password required
Toggle for password to be required for all IO operations.
to access table
Permit READ only
Toggle for read-only access when no password is supplied.
access without
Password is required for write access only.
password
Encrypt data Indicates that the data that is written to the file is encrypted.
Mask Password Hides the password from view.