Generate Scripts for Creating Database Tables

The application data that is modeled by database entities in the IDE must be stored in a database that matches the modeled definitions.

In a production environment, and for systems that do not allow tables to be created on the fly, the developer can generate SQL scripts which the database administrator can execute to create the tables and any relevant indexes and stored procedures in the target database.

  1. In the Uniface assignment file (by default dbms.asn), add the DBMS connector declaration and parameters for your target DBMS.

    For example, to generate referential integrity in a Microsoft SQL database, add MSS settings to the assignment file, setting the desired connector options.

    [DRIVER_SETTINGS]
    ;settings used for Uniface Repository:
    SLE     U1.0
    USYS$SLE_PARAMS create db = on, identifiers = quoted
    
    ;settings used for target application database:
    MSS     U5.2
    USYS$MSS_PARAMS identifiers = quoted, procedures=on, dbms ri

    For more information, see Configuring the Database Connector.

  2. Run the Uniface IDE with the /genSql command line switch, specifying the createtable script type, the entities for which to generate the script, and the target database. For more information, see /genSql.

    For example, the following command generates a file containing the commands to create tables for all entities with SALES as the model suffix of the entity name in a Microsoft SQL Server database.

    /gensql createtable *.sales mss

    Uniface does the following:

    1. Analyzes (compiles) the entities that match the profile, which generates entity descriptors.
    2. Generates a file containing the SQL commands required to create tables in an MSS database, based on the entity descriptors.

    If SQL script generation fails, Uniface returns a warning or error. For more information, see SQL Generation Messages.

  3. To create the tables, have the database administrator run the generated SQL command file using the DBMS. For more information, see the connector documentation for your DBMS connector.

Related Topics