Converting c-tree and Pervasive.SQL tables

The following procedure describes how to write a table conversion procedure for c-tree and Pervasive.SQL tables.

  1. Duplicate the table definition that you will be changing.

In Dexterity, select the table you will be changing in the Resource Explorer, and choose Duplicate from the Utilities menu. Name the duplicate table definition. We suggest you give the duplicate table definition a name that indicates it was the original or old table definition. When you’ve finished, click OK.

  1. Determine which tables have changed and need to be converted.

As an example, the table definition for the Seller_Data table for the Real Estate Sales Manager application will be changed as follows:

  1. Make the necessary changes to the old and new table definitions.

Use the following chart to determine how to change the table definitions.


To do this

Perform these actions

Add new fields to the table

Add the new fields to the new table definition.

Remove fields from the table

Remove the fields from the new table definition.

Add, change or remove keys

Add, change or remove keys from the new table definition.

Change the storage size of fields

Create a “placeholder” field that has the same control type, keyable length, and storage size as original field you’re changing. In the old table definition, insert the placeholder field in place of the field you’re changing. Next, change the data type for the field you’re changing to reflect the new size. Finally, open the table definition for the new table so the correct buffer size is calculated.

Continuing the example, the duplicate table definition for the Seller_Data table was named Seller_Data_OLD. The new Initial Contact Date field was added to the Seller_Data table definition. The new key was also added to the Seller_Data table definition. The size of the Seller Name field was changed using the following steps:

  1. Write the table conversion procedure.

Use the Table_StartConversion() and Table_EndConversion() functions in the conversion process. The table conversion procedure reads each record in the original table and copies it to the new table. During this process, fields you added should be given default values, fields that won’t be in the converted table aren’t copied, and changed fields are copied from the placeholders in the old table to the correct field in the new table. Also, a new table index is automatically created for any new or changed keys.

The Table_StartConversion() and Table_EndConversion() functions can’t be used with SQL Server.

Use the example for the Table_StartConversion() function as a template when you’re writing your own table conversion scripts.

  1. Determine how the table conversion script will be called.

In some cases you may want to call this script from a maintenance window in your application. Table conversion scripts can also be run as installation scripts during the update process, which is described in the next section.

In instances when several tables need to be converted, you may want to write a separate Dexterity application to perform necessary table conversions.

Documentation Feedback