For some databases, you can import the data dictionary definitions of an existing database into the application model using the Load Definitions facility, which is provided in Project Editor, in the Tables tab of the Resource Browser.
Uniface can load tables, views, columns, indexes and relationships, but not all objects are necessarily supported. For more information, see the documentation for each DBMS.
Before using Load Definitions:
- In the [DRIVERS] section of the assignment file, supply the connector to load. For example
MSS = U5.2
- In the [PATHS] section, define the path to access the database from which to load the definitions.
For the left hand side of the path definition, use the DBMS mnemonic of your database, so to access Microsoft SQL Server specify the connection details to $MSS, to access Oracle supply $ORA, etc.
For the proper syntax of the right hand side, see the Database Access section in this documentation for your DBMS.
$MSS = mss:myODBCDataSource:myDB|myuser|mypassword
Ensure you have the appropriate privileges to read the DBMS system tables.
To import data definitions from a DBMS:
- In the Project Editor, select the Tables tab in the Resource Browser. This is the Load Definitions facility.
- In the upper part of this panel, specify the model name for the entities that will be loaded, as well as the templates to use for Tables and Views. The templates contain code and properties for the generated entities.
The default model name is
MODEL. You can specify any other string for the model name.
The default templates the IDE supplies and uses are UENTTABLE.MODEL for tables, and UENTVIEW.MODEL for views. You may create and use your own templates.
Note: For fields and indexes, no templates can be supplied.
Note: The utility generates comments for each loaded entity, reporting that this is a generated entity, and supply a generation date.
- In the lower part of this screen, use the U-Bar to navigate to your database, and then to the proper name space. The name space differs per DBMS. It can be a database schema, a database name, a user name, and so on.
If the path to your DBMS is not defined or accessible, no name spaces can be displayed and you will see an error message instead. For example, for Microsoft SQL server it would be: No database connection over path $MSS.
- To generate tables and views, select one or or more tables and views, and drag them onto the Project, or choose the applicable Insert option from the context menu.
- You can open and review the generated entities to further enhance them:
- Define primary keys for entities derived from views, as views have no Primary Key, while Uniface requires a Primary Key for each DB entity.
- Create relationships between the entities.
- Etc, see Define a Modeled Entity.
- You are now ready to create a Uniface component with these generated entities. To deploy such components you need to specify the path to the database. The DB path for the generated entities is $DEF (or as specified in your own template). To access this same database using the new entities, make sure you assign the same path as used during the load; assign this path in the [PATHS] section of the assignment file to $DEF, or use it for specified entities in the [ENTITIES] section.
The Uniface entity names are derived from the system catalog of the DBMS. The name of the table or view is converted to uppercase in Uniface. If an entity with the same name already exists in the specified model, Uniface does not overwrite it.
Uniface keys (or indexes) are derived from the indexes in the DBMS. The primary key of a table is generated as Primary Key in Uniface. If an index is unique but not a primary key, it becomes a Candidate Key in Uniface, while other indexes become a normal Indexin Uniface.
Note: Views have no primary key. You need to define a primary key for the generated entity before you can use it.
Uniface fields are derived from column definitions. The column names are converted to uppercase.
The Load Definitions facility maps data types to Uniface data types and packing codes . For more information, see the Data Packing topic for the specific DBMS in this documentation. .