Database Xcessory Tutorials


This section includes the following hands-on tutorials:

Note: We recommend that you print these tutorials for easy reference. To print out any tutorial, click on the right-hand frame before accessing your HTML Browser's File/Print command.


Setting Up the Tutorials

If you haven't yet installed DX, click here for Installation Notes.

Code for the tutorial examples is located in the following directory:

<mt_point>/examples/<example_name>

These examples are based on a small order-entry database. A script is provided to create and populate the database directories:

Informix users

Sybase users

Oracle users

About the OrderEntry Sample Database

The tutorials in this chapter use the OrderEntry database. The OrderEntry database is a simple set of tables intended to support an invoicing application for a sports equipment sales company. The database consists of several tables with keys that allow rapid joining of the tables. Some of the tutorials use joined tables to demonstrate some of the more sophisticated features of Database Xcessory and DBPak.

This distribution includes command files to create the OrderEntry database. If you choose to build these sample applications, create the databases on your own system by using the scripts

Oracle users

Informix users

OrderEntry tables

The tables in the OrderEntry database are listed as follows:

Accounts A list of all customers who have ordered or might plan to order from the company. Indexed by Account_Number, an integer key which should be unique for each record.
Inventory A list of all items that may be ordered. Part_Number is the key and should be unique.
Invoice A table of orders placed with the company. Keyed on Invoice_Number, an integer key which should be unique for each record. Also refers to the Account table through the Account_Number field.
InvoiceDetail Has one record for every line on an order form. Related to the Invoice table through the Invoice_Number column. Invoice_Number column and the Line column together make a unique key, allowing records to be updated.
Sales Contains name of every sales employee in the company, keyed on the Employee_Id, a unique integer field. Territory field is a territory name that can be used later for generating statistics on sales by territory.
SalesByTerritory A view and not an actual table. Data in the view is constructed when the application requests it, an is based on the Invoice and Sales tables.
keys Used to help generate unique keys for other tables. Each row of keys table has a tablename and nextkey pair where the nextkey is the next unique key value for the table in the tablename field. For example, the first record of keys has:

Tablename: Nextkey:

Accounts 3000

where 3000 is the value of the next available unique key for the Accounts table.


Tutorial 1: Simple Forms-Based Application

This tutorial describes how to build a simple form-based database application that allows users to view and edit customer records from the Accounts table. Using Database Xcessory, you simply select fields from the Schema Browser window and drag them to the application under construction. Database Xcessory will automatically set all the resources to the correct values.

A Simple Forms-Based Application

Creating the Container

Widgets in an Xt (X Toolkit) based application are arranged in a hierarchical parent-child structure. Shell widgets are parents to containers that contain other containers and more fundamental primitive widgets. The primitive widgets are usually the ones into which you enter data and with which you interact.

Any window in your finished application must have a container, which must be inside a shell. The container holds the widgets that make up the form.

Using Database Xcessory, all you have to do to begin is create a container. This is because Database Xcessory will automatically create a shell if you create a container without a parent.

Bulletin board

The container we'll use in this application is a bulletin board (XmBulletinBoard). The bulletin board allows you to place children (labelled text fields, in this case) anywhere inside the bulletin board. A bulletin board imposes no constraints on the position of its children. The advantage of using the bulletin board as a container is that it is very easy to use. The disadvantage, for more sophisticated applications, is that it doesn't do anything special when the user resizes the window.

Creating a bulletin board

Use the following steps to create a bulletin board widget that will serve as the parent widget for the XiDBDataField widgets you will create later in this tutorial.

  1. In the Palette, click on the Containers tab to display the Container widgets.
  2. Click on Bulletin Board.

Notice the square widget outline that appears.

  1. Move the outline to the location on the root window where you want to place the bulletin board.
  2. Hold down MB1 and drag down and to the right to resize the widget to 4 inches wide by 3 inches long on your display.

A top level shell widget is automatically created with a bulletin board inside of it. The hierarchy of these widgets is displayed as a tree display in the Browser window. The top level shell is typically used for windows that will be displayed most often in an application. You can create other types of shells, depending on the application. These are described in the Builder Xcessory Users Guide and Builder Xcessory Reference Manual.

Using the Schema Browser to Add Data Fields

Oracle users

Once you've created a container, the next step is to add the labelled data fields using the Schema Browser window. You can use the Schema Browser as if it were a palette of Data Presentation widgets. Drag field names from the Schema Browser to the application. Database Xcessory then creates data fields, graphs, tables, and other Data Presentation widgets with the resources automatically set to display and edit that field (if editable; for example, if you create a graph instead of a data field, that graph is not editable).

Adding labeled fields

Use the following steps to add labelled data fields as children of the bulletin board container you have already created:

The Database list (Sybase) or Owner list (Oracle) is located in the upper right corner of the Schema Browser. To display all available databases (Sybase), or owners (Oracle), click on the down arrow. Click on a database name (in this case, OrderEntry) or owner name (in this case DBPak) to select it.

The Tables list is located on the left side of the Schema Browser. Click on the Accounts table to select it.

The Columns window list now shows all the columns that correspond to the Accounts table along with their data types. The Sample Data window at the bottom of the Schema Browser now displays data that has been read from the first set of rows in the table.

Declarations of Accounts Table (Sybase version).

Selecting Data Fields

Check that Data Field is selected in the Object Type option menu of the Schema Browser. (The Object Type option menu is located in the upper left corner of the Schema Browser.)

To display the option menu:

The Object Type option menu displays the type of widget that will be created when you drag a field from the Schema Browser. Most other DBPak widgets can also be created with the Schema Browser.

Toggling on the Labeled Fields

Check that Labeled Fields is toggled on in the Schema Browser Option menu. The Option menu is in the menu bar at the top of the Schema Browser. The Labeled Fields menu option is toggled on by default.

 

Multiple Columns Selected

One XiDBDataField will be created in your interface for each column definition selected. These widgets are pre-configured to display data from the columns selected in the Schema Browser.

Database Xcessory creates the Data Source, Query and Data Field widgets. The children of the bulletin board, in the Browser object instance hierarchy look like the Instance Hierarchy shown below:

Instance Hierarchy

Notice that two objects, q_Accounts (Query widget) and orderEntry (Database Access widget) for Sybase, or q_ACCOUNTS and test for Oracle, have been created but are not physica>


Transfer interrupted!