Data Dictionary Objects 

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:

Example:

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

PxPlus DDF/DDE Files

 

pvxdb

PxPlus embedded Data Dictionary information from a physical file

Primary Methods

Db_Manager contains three primary methods:

Tblinfo Methods

Description

ReadDefn( )

Reads the table definition from the providex.ddf and providex.dde files, an external database, or a physical file with an embedded dictionary definition (determined by sourcedb parameter) and stores it in a temporary location.

CreateTable( )

Retrieves the table definition from the temporary location and either creates a physical file with an embedded dictionary definition, a table in an external database, or the providex.ddf/providex.dde definitions (determined by destinationdb parameter).

DropTable( )

Drops a table from the providex.ddf/providex.dde files, an external database or a physical file with an embedded dictionary definition (determined by destinationdb parameter).

Different parameter values are used for these methods depending on the source or destination database. See the sample programs below.

Database Interface Examples

The following sample programs illustrate the functionality of the Db_Manager Object:

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:\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$,UpdateTable,GroupName$)

Updating the table in the providex.ddf/providex.dde files:

Ddfpath$="c:\demo\data"
FilePath$=""
UpdateTable=1
GroupName$="" db'CreateTable(dbConstants'getDatabaseID("pvxddf"),ddfpath$,FilePath$,UpdateTable,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:\demo\data"
TableOk=db'ReadDefn(dbConstants'getDatabaseID("pvxddf"),Table$,Ddfpath$)

Updating the physical file:

FilePath$="cstfile" UpdateTable=1
db'CreateTable(dbConstants'getDatabaseID("pvxddf"),FilePath$,UpdateTable)

Updating the table in the Microsoft SQL-Server database (ADO):

ConnectOpt$="user=sa;pswd=admin;db=test"
DSN$="ws2003-x86-pdb.pvx.com"
UpdateTable=1
db'CreateTable(dbConstants'getDatabaseID("ado"),Table$,ConnectOpt$,DSN$,UpdateTable)