Products Support Documentation Download
Create the v14-format database

In the v14 environment:

Convert DDL to New SQL DDL
Generate the SQL DDL and a source code editing script with the rdm-convert utility:
rdm-convert --sed-d dbname.ddl

Use '–sed' rather than '–sed-d' if your original DDL is compiled without the '-d' (duplicates allowed) command-line option.

Note
This utility will produce a set of warnings that may require updates to your application code to fix. For example, v14 doesn't support sets with order FIRST, LAST or NEXT.

Two files will be generated by rdm-convert: dbname.sdl and dbname.sed. The .sdl file is SQL DDL, and you will use it to compile your new database schema. The .sed file is a script for the 'sed' stream editor, used for editing source code with mechanical changes.

Create the New Database
Create the new database using rdm-sql:
$ rdm-sql
rdm-sql: create database dbname;
rdm-sql: .r dbname.sdl
rdm-sql: commit;

It is likely that the '.r dbname.sdl' failed because of compilation errors due to SQL reserved words. If this happens, perform the following steps and repeat step 2 above.

  • Remove the partially created database. It is a subdirectory named dbname.rdm. You can remove it and any contents.
  • Edit the .sdl file and change the reserved word to a similar but non-reserved word. For example, a table named TRANS is using an SQL reserved word. In the .sdl file, it can be changed to something like TRNSCTN.
  • Edit the .sed file. In this file, you will see a series of substitute commands. Search for your reserved word and replace only the 'replace with' text with your new word. For example:
    s/\\bINV_TRANS\\b/REF_INV_TRANS/g
    becomes s/\bINV_TRANS\b/REF_INV_TRNSCTN/g and
    s/\\bTRANS\\b/TABLE_TRANS/g
    becomes s/\bTRANS\b/TABLE_TRNSCTN/g
  • Repeat until the SQL DDL successfully compiles.
Load the Database
Load the database by importing the CSV files. You need to have a series of SQL IMPORT statements, which you may enter by hand or create within a text file. For example, a file named 'imports.sql' can be created with content similar to this:
import into table1 from file "table1.csv";
import into table2 from file "table2.csv";
...
import into tableN from file "tableN.csv";

Then run rdm-sql to do the work:

$ rdm-sql
rdm-sql: use dbname;
rdm-sql: .r imports.sql
rdm-sql: commit;

A Note about ordering of the imports: RDM 12 set definitions are implemented in v14 SQL as foreign keys, where the member record (SQL row) references the primary key of the owner record. This will happen automatically when you import data if all referenced rows are created before the referencing rows. In other words, all owner records must exist before the member records exist.

Study your original DDL file, or the SDL file produced by rdm-convert. Order the insert statements such that the owner/primary rows are inserted before the member/referencing rows.

Sometimes there are circular references in databases, where one or more tables create a cycle. This normally creates a tree structure in the rows. It means that it is not possible to order the imports in a way where all primaries exist first. If you have this situation, perform the following steps:

  1. Order the imports with primary rows created before referencing rows as much as possible.
  2. Issue the statement "SET IGNORE IMPORT ERROR TO ON;" before the import statements.
  3. Count the number of lines in each CSV file.
  4. Following the procedure in step 3 above, perform the imports.
  5. For every CSV file that is imported, the number of successfully imported lines will be displayed. If all lines for this CSV file were imported, then remove this file from further processing.
  6. If some of the imports were incomplete, rerun the incomplete imports. Order is important. Rerun the imports cyclically in the same order each time.
  7. Repeat the imports until the total of successfully imported lines equals the number of lines in the CSV files, or until there are no new rows imported.
  8. Commit the imports. Query the database to verify completeness.
    Note
    NOTE: the above procedure will result in duplicated lines if there are multiple imports of rows with no primary or unique keys. If any of your table definitions will allow duplicates, be sure to remove them from multiple import attempts.
    Convert the Source Files
    Convert the source files. The sed script generated by rdm-convert and possibly enhanced by you to account for reserved words should now be used on the source files. Sed is available for download to Windows, and will already be present in any Linux or Unix installation. Make sure you have backup copies of your source files, as this procedure might overwrite them in place. Run:
    sed –i -f dbname.sed *.c *.cpp
    
    Generate the database header file (dbname_structs.h) using rdm-compile:
    rdm-compile –s dbname.sdl
    

If your source files include dbname.h, you will need to change the include statement to:

#include "dbname_structs.h"

If your source files include dbname_dbd.h, change to dbname_cat.h.

If you include system header files (those with angle-brackets like <stdio.h>), you will need to move all of them to follow the RDM headers.

Compile the Program(s)
Build the program(s). Whatever the IDE or workbench you are using, you will need to change the compile and link options and use the v14 libraries. Given the number of permutations possible, we will not cover all configurations here. But here are some general guidelines.
  • Reference the v14 'include' directory when you compile.
  • If your RDM SDK is 64-bit, define RDM-64BIT (-DRDM-64BIT).
  • Reference the v14 'lib' directory when you link.
  • Use the following set of libraries. Ordering may be important:
    rdm_legacy, tfs_legacy, tfs, http, rdm, ddl, rdmenc_simple, rdmtransport, tx, base, psp