Using SQL Access
Complete the following tasks to take advantage of SQL access:
1
2
3
4
Step 1: Modify the Sample XML Templates
Pervasive PSQL v11 SP3 includes sample XML templates that you use to define the layout of data as required by your COBOL application. See Table 196. In developer’s terms, you describe your metadata in the XML files.
1
2
3
Step 2: Copy the Data File Specified in the XML Template
Copy the data file(s) specified in the XML file to the data file location of the database before you run Schema Executor. The database is the one to which you need to add the tables.
For example, you want to add a table (specified in the XML as mytable.mkd) to a database "test" that has its data files under c:\data\test. Copy the data file mytable.mkd to c:\data\test before you run Schema Executor.
Step 3: Run the Schema Executor Utility
Pervasive PSQL v11 SP3 includes a command line utility called the Schema Executor, which is also referred to as SchemaExec.
Schema Executor performs the following actions:
See also Example of How to Execute a Sample XML File.
1
2
Execute Schema Executor at the command line (see Table 196 for where this executable is installed by default).
Provide the required options, XMLfilename and databasename, and any desired optional options. See Schema Executor Command Format.
If errors occur during the processing of the XML content, review the errors reported in the Schema Executor log file. See Log Messages. Re-execute the utility with corrected XML until no errors result from the processing.
Schema Executor Command Format
cobolschemaexec XMLfilename databasename [-s servername] [-u login_id] [-p password] [-i svr_loginid] [-c svr_password] [-l log_file] [ -h | -? ]
 
-u login_id
The user name required to access a secure database. See Pervasive PSQL Security in Advanced Operations Guide for a discussion of the Pervasive PSQL security models.
-p password
The password required to access a secure database. See Pervasive PSQL Security in Advanced Operations Guide for a discussion of the Pervasive PSQL security models.
-i svr_loginid
-c svr_password
-l log_file
If you execute SchemaExec on a client machine (a machine not running the Pervasive PSQL database engine), you can specify a log file for the client machine.
*Note: The required options XMLfilename and databasename are positional and must appear in that order.
Example Usage
The following examples illustrate usage of Schema Executor.
For default locations of Pervasive PSQL files, see Where are the Pervasive PSQL files installed? in Getting Started With Pervasive PSQL.
cobolschemaexec file_path\PSQL\samples\cobolschemaexec\test.xml demodata\
cobolschemaexec file_path\PSQL\samples\cobolschemaexec\test.xml mytest
The utility prompts as follows:
CB103 : Could not connect to mytest
Do you want to create database (y/n) ?
If you press "y," the utility prompts for a database path:
Please enter the Database Path:
Provide an existing path or the utility returns an error. Ensure that the database file (for example, a .MKD file) being used in the XML file is available in the path.
cobolschemaexec file_path\PSQL\samples\cobolschemaexec\test.xml demodata -s TestMachine -i testuser -c testuser
This example assumes that a user "testuser" (with password "testuser") exists on the remote machine (TestMachine) with administrative privileges, and that the database file being used in the XML file is available in the data file directory of the database on the remote machine.
cobolschemaexec file_path\PSQL\samples\cobolschemaexec\test.xml mytest -s RemoteMachine -i testuser -c testuser
This example assumes that a user "testuser" (with password "testuser") exists on the remote machine (TestMachine) with administrative privileges.
The utility prompts as follows:
CB103 : Could not connect to mytest
Do you want to create database (y/n) ?
If you press "y," the utility prompts for a database path:
Please enter the Database Path:
Provide an existing path or the utility returns an error. Ensure that the database file (for example, a .MKD file) being used in the XML file is available in the path.
Creating a New Database with Schema Executor
If the utility option databasename specifies a database that does not exist, Schema Executor prompts you whether to create a new database. If you specify “yes,” the utility prompts for a location of the new database. The location (path and folder name) must already exist for Schema Executor to create the database.
Note that Schema Executor also expects to find the data files for databasename in the default folder. The utility informs you if it finds no data files. Manually copy the data files to the default folder and run Schema Executor again to process the XML.
Log Messages
This section lists the codes that may appear in a log file after processing an XML file with Schema Executor.
The success code is CB100 : Schemaexec completed successfully.
The following table lists the error codes.
TableName - Duplicate TableName
FieldName - Duplicate FieldName
IndexName - Duplicate IndexName
Identifier - contains invalid characters
TableFilter - TableFilter cannot have more than 255 characters
FieldName is not a field of TableName
Identifier name identifiername should start with an alphabetic character
Identifier name identifiername cannot be a keyword
DataFile - doesn't exist at DatabasePath
Could not create database DatabaseName in the dictionary path Databasepath
Step 4: Optionally, Deploy the System Tables
If you are a COBOL applications developer, ensure that you deploy all of the system tables with your application. Such deployment is nothing new and is mentioned only because you may have additional system tables. For example, Schema Executor creates additional system tables and populates them if you run the utility against a database created with a version of Pervasive PSQL prior to Pervasive PSQL v11 SP3. Therefore, you may have a few additional system tables (DDF files) to deploy.