16.5 The RUNSQL Utility
16.5.1 Configuration Notes - Creating Tables and Indexes
All Visual LANSA systems are shipped with a utility named RUNSQL.
RUNSQL can be used to automatically create the definition of a table into any supported DBMS system.
RUNSQL, combined with a .CTD (Common Table Definition File) file created by Visual LANSA during table compilation, form the essential ingredients that you need to move table definitions (not data) between different supported DBMS systems.
To understand how RUNSQL works consider this diagram:
If you imagine that you are attempting to transfer the definition of a table named PSLMST (that you have previously defined and compiled in your development environment) into another DBMS, then the key things shown in this diagram are:
- When the RUNSQL utility is invoked it reads in the file named PSLMST.CTD. This is the "Common Table Definition" (CTD) of table PSLMST that is created by Visual LANSA whenever you compile a table in your development environment. It defines table PSLMST and its associated views and indices in a common cross platform / cross DBMS format (full details of the format of .CTD files can be found in another section of this guide).
- RUNSQL also reads in a standard Visual LANSA file named X_DBMENV.DAT (Database Environment Definitions) that defines the unique characteristics of the DBMS that it is about to work with.
- By using PSLMST.CTD and X_DBMENV.DAT the RUNSQL utility can assemble the unique "create" commands appropriate for the selected DBMS.
- Once the "create" commands are assembled the DBMS is invoked (via ODBC in Windows environments) and it is asked to create the necessary table, view, indices, etc.
RUNSQL is a simple program. It has the following positional and non-positional parameters:
|
Non-Positional Parameters
|
Note that non-positional parameters can be placed anywhere on the command line separated by spaces from the other arguments.
For example, this command executed from the x_Lansa\source directory compares myfile.ctd to myfile_old.ctd and makes the changes to the table. Note that it also uses the x_dbmenv.dat file from the parent directory - – which in this case is the x_lansa directory:
..\execute\runsql myfile.ctd OLDCTD=myfile_old.ctd LX_LANSA Y Y SQLANYWHERE DBA/SQL