2
Creating a Starter Application
This chapter describes how to use Oracle AppWizard for Microsoft
Visual C++ to create a starter application.
Topics include the following:
Overview
After starting Oracle AppWizard, you complete a series of
steps in which you specify which of three application types you want to
create, as shown in the table below.
When you finish the last step, Oracle AppWizard for Microsoft
Visual C++ generates the application. Application files include the following:
-
Source files
-
Header files
-
Resource files
-
Standard MFC project files
-
A ReadMe.file describing of all the files of which
your application consists
You then build and run the executable, using Microsoft Visual
C++.
The first three steps are the same
whether you create a single-record, multiple-record, or a master-detail
display.
Starting
Oracle AppWizard for Microsoft Visual C++
To start Oracle AppWizard for Microsoft Visual C++:
-
Start Microsoft Visual C++ 5.0.
-
Choose File > New.
The New dialog box appears.
-
Click the Projects tab.
-
Select Oracle AppWizard for MFC (exe) from
the list of project types.
-
Specify the project name and location.
-
Click OK.
Oracle AppWizard for Microsoft Visual C++ starts.
Creating
a Single- or Multiple-Record Display Application
This section describes how to create a single- or multiple-record
application.
Welcome
Window
The Welcome window is the first window you see when you start
Oracle AppWizard.
Click Next to continue.
Connecting
to an Oracle Database
In the Connection window, you connect to an Oracle database.
To connect to the Oracle database:
-
Type your user name in the User Name text box.
-
Type your password in the Password text box.
-
If connecting to a remote database, type the database
alias in the Database Alias text box. If connecting to a local default
database, leave the text box blank.
For more information about database aliases,
refer to the Oracle Net8 Administrator's Guide.
-
Click Next.
Specifying
the Type of Form
Use the Form Type window to generate a specific type of form,
to give it a name of your choice, and to specify the database privileges
for users.
Forms can be single-record, multiple-record, or master-detail
display:
-
If you want your form to show information from a
database table one record at a time, select single-record display mode.
-
If you want your form to display multiple records
from a database table at one time, select multiple-records display mode.
-
If you want your form to display information in Master-Detail
format, select master-detail record display mode.
For example, if you select any or all database permissions
for your users, Oracle AppWizard generates code for this purpose. This
enables methods that allow the users of your application to update data.
If you do not select any data usability options, Oracle AppWizard does
not generate code for this purpose and the form will be read-only.
To complete the Form Type window:
-
Type the name of the form. Each form name must be
unique and the first character of the form name must be a letter. The rest
of the form name must be alphanumeric.
Example
2-1:
a1b3eux
-
If you want to create a single-record display form,
select Single-Record Display Form.Or, if you want
to create a multiple-record display form, select Multiple Record Display
Form.
-
If you want users to be able to add records, select
the Add New Records checkbox.
-
If you want users to be able to change records, select
the Change Existing Records checkbox.
-
If you want users to be able to delete records, select
the Delete Existing Records checkbox.
-
Click Next.
Selecting
Tables and Columns
In the Tables/Columns Selection window,
you select columns from the tables you want the form to reference. The
tables available to you appear in the list.
To complete Tables/Columns Selection window:
-
Select one or more tables from the list to appear
in your application. By default, all the columns of the table you select
are also automatically selected unless you manually deselect them by clicking
them.
-
The Update, Insert, and Delete options, specified
in the Form Type window, work only with a single table. If you select multiple
tables and have checked these options, the following error message appears:
Add, Change, and Delete are supported in applications using a single table.
You have selected multiple tables.
Database Functionality defaults to Read Only.
-
If necessary, expand the table you selected and select
additional columns that should be displayed in the application.
-
Click Next.
Specifying
One or More Joins (Optional)
Oracle AppWizard for Microsoft Visual C++ automatically creates
a simple join (also called an equi-join) between two tables, or views,
based on a Primary Key and a Foreign Key.
Such joins are used in the WHERE clause
of a SELECT statement to avoid a Cartesian product, which would combine
every row in one table with every row in an other table. For example, a
90-row table combined with a 100-row table would produce a 9000-row result.
Additional
Information:
See the description of the SELECT command in Chapter 4 of
Oracle SQL Reference for more information about various types of
joins and Cartesian products. |
Tip:
When selecting tables or columns, use the Ctrl key and your
mouse to select items that are not adjacent. Also, you can use the Ctrl
key and your mouse to deselect an item.
|
The Oracle AppWizard Table Join window displays a join in
the following format for single or multiple tables:
SCHEMA.TABLE_NAME.COLUMN_NAME [DATA_TYPE] joins SCHEMA.TABLE_NAME.COLUMN_NAME
[DATA_TYPE]
If for some reason you do not want to use the suggested
join created by Oracle AppWizard for Microsoft Visual C++ (shown in the
previous illustration), you can delete it and create a new join. Alternatively,
you can also do this by modifying the WHERE clause of a query statement
in the source file generated by Oracle AppWizard.
To accept the default join:
To delete the default join:
-
Highlight the default join displayed in the Table
Joins list in the Table Join window.
-
Click the Delete Join button.
Oracle AppWizard for Microsoft Visual C++ deletes
the join.
To create a new a join:
-
Highlight two columns from different tables that
you want to join by using your mouse and the Ctrl key.
The join appears in the Table joins list with
the following syntax:
SCHEMA.TABLE.COLUMN [DATA_TYPE]
joins SCHEMA.TABLE.COLUMN [DATA_TYPE]
Note:
You can specify more than one join.
|
-
Click Next.
Oracle AppWizard prompts you as to whether you
want to build another form. If you decide to create a new form, you will
not be able to go back and use AppWizard to modify the form you have already
created.
-
If you want to build another form, click Yes and
Oracle AppWizard will take you back to the Application Type window.
-
If you do not want to build another form, click No.
Note:
If you only specify one table, Oracle AppWizard skips the
table join step.
|
Specifying
the Application Type and User Language
When you are finished building forms and click Next, you
are ready to specify the application type and the user language.
To complete the Application Type window:
-
Indicate the type of application you are creating
by clicking the appropriate option:
-
Single document
-
Multiple documents
-
Dialog-based
Note:
Dialog-based applications are not supported in the current
release.
|
-
In the list box, select the language appropriate
for your application, or accept the default language.
-
Click Next.
Completing
the Remaining MFC Windows
Complete the remaining standard MFC windows as appropriate
until you reach the window illustrated below. For more information about
MFC windows, refer to your MSVC++ documentation.
Viewing
the Application Classes
In the Class Information window, Oracle AppWizard for Microsoft
Visual C++ displays the classes it will create for your application, including
their names, header files, base classes, and the implementation file.
To complete the Class Information window:
-
Review the list for completeness and accuracy:
-
If you are not satisfied with the listed classes,
click Back to go to the appropriate previous dialog box to make changes.
-
Depending on which class you have selected, you may
change the class name, header file name, and the implementation file name.
If you rename these files, the first character must be a letter. The rest
of the name must be alphanumeric.
-
When you are satisfied with the result, click Finish.
The New Project Information window appears.
Viewing
the Specifications for the New Application
The final window, New Project Information, displays the specifications
for the new skeleton application you are creating.
-
If the specifications appear to be correct, click
OK.
Oracle AppWizard generates the files for your
single-record or multiple-record application.
-
If the specifications are not correct, click Cancel.
Creating
a Master-Detail Display Application
This section describes how to create
an application that can display records from two or more tables that have
a master-detail relationship.
The first three windows are completed
in the same way as those described in "Creating a Single-
or Multiple-Record Display Application," on, except that, for a master-detail
display, you will complete the Application Type window as follows:
-
Select Master-Detail Display Form as the database
form type
-
Optionally, you can permit the user of your application
to perform the database operations listed in the Application Type
window by selecting any or all of the three check boxes.
Specifying
the Type of Form
In the Form Type window, type the name
you want to give the form, select the type of form, and the database privileges
that your application requires.
Selecting
Master Tables and Columns
In the Master Table/Column Selection
window, the master tables available to you appear in a list.
To complete the Master Table/Column Selection window:
-
Select the master table columns from the list. In
the example above, the Department table is the master table. All the columns
from the Department table have been selected.
-
If necessary, expand the table you selected by clicking
the '+' to the left of the table name and change which columns are to be
displayed in the application.
-
Click Next.
Selecting
Detail Tables and Columns
In the Detail Table/Column Selection
window, the detail tables that are available to you appear in a list. Select
the detail tables and the columns that you want displayed in the application.
To complete the Detail Table/Column Selection window:
-
Select columns from one or more detail tables in
the list. In the illustration above, the Employee table is the detail table.
The Employee table and all of its columns have been selected.
-
If necessary, expand the table you selected by clicking
the '+' to the left of the table name, and change which columns are to
be displayed in the application.
-
Click Next.
Building
a Join Clause
After you have selected the tables
between which you want to set up a master-detail relationship, you use
the Master/Detail Table Join window to specify how to join the columns
from each of the tables you selected in the last two windows.
Oracle AppWizard for Microsoft Visual C++ automatically
creates a simple join (also called an equi-join) between two tables, or
views, based on a Primary Key and a Foreign Key.
Such joins are used in the WHERE clause of a SELECT
statement to avoid a Cartesian product, which would combine every row in
one table with every row in an other table. For example, a 90-row table
combined with a 100-row table would produce a 9000-row result.
If for some reason you do not want to use the default join
created by Oracle AppWizard for Microsoft Visual C++ (shown in the previous
illustration), you can delete it and create a new join. Alternatively,
you can also do this by modifying the WHERE clause of a query statement
in the source file generated by Oracle AppWizard.
If you want to create more than one
join, choose one column from the master table and one column from the detail
table to create each additional join clause.
To accept the default join in the Master/Detail
Table Join window:
To delete the default join:
-
Highlight the default join displayed in the Master
and Detail Table Joins list in the Master/Detail Table Join window.
-
Click the Delete Join button.
Oracle AppWizard for Microsoft Visual C++ deletes
the join.
To create a new a join:
-
Select one column from the master column list.
-
Select one column from the detail column list.
The join appears in the Master and Detail Table
Joins list with the following syntax:
Master - SCHEMA.TABLE_NAME.COLUMN_NAME [DATA_TYPE] joins Detail -
SCHEMA.TABLE_NAME.COLUMN_NAME [DATA_TYPE]
-
(To create multiple joins, repeat Steps 1 and 2.) If
you want to delete a join from the Master and detail joins list, highlight
it and click Delete Join.
-
Click Next. Oracle AppWizard asks you whether or
not you would like to build another form.
If you want to build another form, click Yes,
and Oracle AppWizard will take you back to the Form Type window.
If you do not want to build another form, click
No.
Specifying
the Application Type and User Language
When you are finished building forms
and click Next, you are ready to specify the application type and the user
language.
To complete the Application Type window:
-
Indicate the type of application you are creating
by clicking the appropriate option:
-
Single document
-
Multiple documents
-
Dialog-based
Note:
Dialog-based applications are not supported in the current
release.
|
-
In the list box, select the language appropriate
for your application, or accept the default language.
-
Click Next to proceed to the standard MFC windows.
Completing
the Remaining MFC Windows
Complete the remaining standard MFC
windows as appropriate until you reach the window illustrated below. For
more information about MFC windows, refer to your MSVC++ documentation.
Viewing
the Application Classes
In the Class Information window, Oracle
AppWizard for Microsoft Visual C++ displays the classes it will create
for your application, including their names, header files, base classes,
and the implementation file.
To complete the Class Information window:
-
Review the list for completeness and accuracy:
-
If you are not satisfied with the listed classes,
click Back to go to the appropriate previous dialog box to make changes.
-
Depending on which class you have selected, you may
change the class name, header file name, and the implementation file name.
If you rename these files, the first character must be a letter. The rest
of the name must be alphanumeric.
-
When you are satisfied with the result, click Finish.
The New Project Information window appears.
Viewing
the Specifications for the New Application
The final window, New Project Information,
displays the specifications for the new skeleton application you are creating.
-
If the specifications appear to be correct, click
OK.
Oracle AppWizard for Microsoft Visual C++ creates
the files for your master-detail application.
-
If the specifications are not correct, click Cancel.
Building
the Executable
After Oracle AppWizard generates the
application, you can build an executable.
Note:
You may want to check the project settings to see if the
they are correct for your configuration. Choose Settings from the Project
menu to view the project settings.
|
To build the executable:
-
Choose Build <executable name> from the
Build menu.
Oracle AppWizard compiles and links your project.
Running
the Executable
Now you are ready to execute the application
you created.
Note:
By default, the active project configuration is the debug
version. To change the active project configuration, choose Set Active
Configuration from the Build menu.
|
To run the executable:
-
From the Build menu, choose Execute <executable
name>.
The Connect to Oracle dialog box appears.
-
Type your User Name and Password.
If connecting to a remote database, type its
alias into the Database Alias text box.
After your application connects
to the database successfully, the form you generated appears showing data
retreived from the database. The following illustration is an sample of
what your form might look like, although the appearance of your actual
form and data will vary based on the database information you select.