Database Import Utility |
The Database Import Utility allows you to define a connection to an existing database (ODB, MySQL, OCI, ADO or DB2) and then selectively import table definitions from the selected database into the PxPlus data dictionary.
In addition, this utility can be used to:
The Create DB File button launches a separate window that allows you to create either a Link file or a Prefix file entry that points to the database itself.
(The Database Import Utility was added in PxPlus 2023.)
(The Create DB File button was added in PxPlus 2023 Update 1.)
The utility remembers database connection information after successfully connecting to the database when the Load Tables button is selected. Multiple database connections can be remembered, one connection for each database type. The connection information is remembered on a "per project" basis. This allows one project to use one database while another project can use a different database easily.
When the utility is invoked, the connection information for the last database that was successfully connected to is automatically loaded into the fields in the Source Database section. If you change the Database Type field and a database of that type previously connected successfully, the remembered database connection information will automatically be loaded.
(The remembering of database connection information was added in PxPlus 2023 Update 1.)
This utility lists all the tables in the database, sorted in alphabetical order by default. A check mark indicates which table definitions are currently in the data dictionary. Options for different Actions can be selected individually for each table, or the Edit All drop down can be used to select an option for all the tables. The selected actions are used to create, merge or replace data dictionary records, create native PxPlus data files, create database link files, and add database table entries to the prefix file.
To invoke this utility, use one of the following methods:
Location |
Method |
Click the Import tool bar button in the Database section of the tool bar. | |
From the menu bar, select File > Database Import Utility. | |
From the PxPlus Command line |
Enter: RUN "*dict/impdb" |
Call Import actions programmatically |
The Database Import Utility is displayed below with a sample entry:
This window consists of the following:
Enter the database information. The utility remembers the database connection information after successfully connecting to the database (when the Load Tables button is selected) and automatically loads this information into these fields when the utility is invoked. (The automatic loading of database connection information was added in PxPlus 2023 Update 1.)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
Button that launches the Create Database Connection File window that allows you to create either a Link file or a Prefix file entry that points to the database itself.
A direct connection to the database may be useful so that you can do a global OPEN to the database, providing the UserID and Password. This avoids needing the UserID and Password on every link/prefix entry. It can also be used to get a list of tables from the database or if your program needs to make direct queries against the database. This window consists of the following:
(The Create DB File button was added in PxPlus 2023 Update 1.) | |||||||||||||||||||||||||||||||||||||||||||||||||||
Button that is used to load tables from the selected database into the Tables grid. If changes have been made in the grid but not applied, a message will display. When the database connection is successful, the connection information (one connection for each database type) is remembered on a "per project" basis and is automatically loaded when the utility is invoked. (The remembering of database connection information was added in PxPlus 2023 Update 1.) | |||||||||||||||||||||||||||||||||||||||||||||||||||
(Tables Grid) |
Grid that lists all the tables in the selected database. This list can be sorted by clicking on the column header for any of the columns except DD Action and File Action. Subsequent clicks toggle the sort between ascending/descending order. By default, the list is sorted by Table name in ascending order. (Column sorting for applicable columns was added in PxPlus 2023 Update 1.) This grid consists of the following:
| ||||||||||||||||||||||||||||||||||||||||||||||||||
Strip User/Password from Link Files and Prefix Entries |
Controls whether the User and Password connection options are stripped from link files and prefix file entries. By default, this check box is selected. For security reasons, it is strongly recommended not to save the User and Password information in plain text. | ||||||||||||||||||||||||||||||||||||||||||||||||||
If selected, disables a warning message from displaying for each File Action that will delete a native file, causing possible data loss. By default, this check box is not selected to help prevent accidental data loss. If you are applying several File Actions and are knowingly replacing native data files, you can set this option to avoid displaying a warning message for each table. | |||||||||||||||||||||||||||||||||||||||||||||||||||
View Log |
(Available when changes have been applied) Displays a log of applied changes as a PDF, which also provides options for printing or saving the log, if desired. | ||||||||||||||||||||||||||||||||||||||||||||||||||
Apply |
(Available when DD Action or File Action is set to other than No Action) Applies changes to all the tables that had a DD Action or File Action set to something other than No Action. A message displays that lists which changes were applied successfully, which changes were incomplete (partially successful), and which changes failed. | ||||||||||||||||||||||||||||||||||||||||||||||||||
Exit |
Closes the Database Import Utility. If changes have been made in the grid but not applied, a message will display. If records exist in the log file, a message will ask if you want to view the log. |
The individual Import actions (i.e. CreateDDRecord, CreateAndLoadFile, etc.) can be invoked programmatically by calling the following routines:
Create/Merge/Replace a Database table into the Data Dictionary
Call "*dict/impdb;CreateDDRecord", db_prefix$, connect$, db_name$, db_user$, db_pass$, db_options$, tableName$, description$, fileName$, groupName$, replace, result$
Where:
db_prefix$ |
Database type. Valid types are "ODB", "MySQL", "OCI", "DB2" and "ADO". If not specified, defaults to "ODB". |
connect$ |
Data Source or Server Address. |
db_name$ |
Database Name or System ID. |
db_user$ |
User login name. |
db_pass$ |
User password. |
db_options$ |
Options to be used as OPT= parameters when opening the database or updating the prefix file. Defaults to NULLPADKEY=Y and NONULLS=Y, except if db_prefix$="OCI", in which case, it is just NULLPADKEY=Y. |
tableName$ |
Name of the table in the database. This will also be used as the data dictionary entry name. |
description$ |
Desired data dictionary entry description. |
fileName$ |
Desired physical file path of the data dictionary entry. |
groupName$ |
Desired data dictionary entry group. |
replace |
Flag indicating if the data dictionary already exists, whether the entry should be merged or replaced. If set to 1, the entry will be replaced. |
result$ |
After the call, check this string for the result of the call. If it worked without error, the result will be "SUCCESS". |
Add to Prefix File Entry for the External Database table
Call "*dict/impdb;AddToPfxFile", db_prefix$, connect$, db_name$, db_user$, db_pass$, db_options$, tableName$, fileName$, stripPswd, noDataLossWarning, result$
Where:
db_prefix$ |
Database type. Valid types are "ODB", "MySQL", "OCI", "DB2" and "ADO". If not specified, defaults to "ODB". |
connect$ |
Data Source or Server Address. |
db_name$ |
Database Name or System ID. |
db_user$ |
User login name. |
db_pass$ |
User password. |
db_options$ |
Options to be used as OPT= parameters when opening the database or updating the prefix file. Defaults to NULLPADKEY=Y and NONULLS=Y, except if db_prefix$="OCI", in which case, it is just NULLPADKEY=Y. |
tableName$ |
Name of the table in the database. |
fileName$ |
Desired physical file path of the prefix file entry. This path can then be used to open the database connection as if it were a physical file. |
stripPswd |
Flag indicating whether the User and Password should be stripped from link files and prefix file entries. If set to 1, the User and Password will be stripped. |
noDataLossWarning |
Flag indicating whether the user should be warned about possible data loss if a native file exists that will be deleted because the prefix file entry replaces it. If set to 1, the user will not be warned. |
result$ |
After the call, check this string for the result of the call. If it worked without error, the result will be "SUCCESS". |
Create Link File for the External Database table
Call "*dict/impdb;CreateLinkFile", db_prefix$, connect$, db_name$, db_user$, db_pass$, db_options$, tableName$, fileName$, stripPswd, noDataLossWarning, result$
Where:
db_prefix$ |
Database type. Valid types are "ODB", "MySQL", "OCI", "DB2" and "ADO". If not specified, defaults to "ODB". |
connect$ |
Data Source or Server Address. |
db_name$ |
Database Name or System ID. |
db_user$ |
User login name. |
db_pass$ |
User password. |
db_options$ |
Options to be used as OPT= parameters when opening the database or updating the prefix file. Defaults to NULLPADKEY=Y and NONULLS=Y, except if db_prefix$="OCI", in which case, it is just NULLPADKEY=Y. |
tableName$ |
Name of the table in the database. |
fileName$ |
Desired path of the created link file. |
stripPswd |
Flag indicating if the User and Password should be stripped from link files and prefix file entries. If set to 1, the User and Password will be stripped. |
noDataLossWarning |
Flag indicating whether the user should be warned about possible data loss if a native file exists that will be deleted because the link file replaces it. If set to 1, the user will not be warned. |
result$ |
After the call, check this string for the result of the call. If it worked without error, the result will be "SUCCESS". |
Create and Load Physical File from the External Database table
Call "*dict/impdb;CreateAndLoadFile", db_prefix$, connect$, db_name$, db_user$, db_pass$, db_options$, tableName$, fileName$, noDataLossWarning, result$
Where:
db_prefix$ |
Database type. Valid types are "ODB", "MySQL", "OCI", "DB2" and "ADO". If not specified, defaults to "ODB". |
connect$ |
Data Source or Server Address. |
db_name$ |
Database Name or System ID. |
db_user$ |
User login name. |
db_pass$ |
User password. |
db_options$ |
Options to be used as OPT= parameters when opening the database or updating the prefix file. Defaults to NULLPADKEY=Y and NONULLS=Y, except if db_prefix$="OCI", in which case, it is just NULLPADKEY=Y. |
tableName$ |
Name of the table in the database. |
fileName$ |
Desired path of the native keyed file to create and load with data from the database. |
noDataLossWarning |
Flag indicating whether the user should be warned about possible data loss if a native file exists that will be deleted because the new native file replaces it. If set to 1, the user will not be warned. |
result$ |
After the call, check this string for the result of the call. If it worked without error, the result will be "SUCCESS". |
Database Export Utility
Bulk Database Export Utility
Creating a Link File
Creating the Prefix File