Previous | Table of Contents | Next
Page 579
This Bonus Day deals with the use of PowerBuilder and Oracle.
PowerBuilder is an application-development environment that can be compared to
Oracle Power Objects. It is the principal product of Powersoft, a wholly
owned subsidiary of Sybase.
PowerBuilder's features include:
- The DataWindow, a flexible and intuitive mechanism for mapping
a database table to an object that can be manipulated in an application
- Support for most desktop and server databases including
Oracle, Sybase, SQL Server, Informix, and SQL Anywhere
- Excellent integration with Windows via DDE and OLE
- Support for distributed objects
Page 580
- A pipeline object that supports data transfer between different database
platforms (for example, from Sybase to Oracle)
- Support for classes, inheritance, and polymorphism
NOTE
|
The examples in this lesson are based on PowerBuilder
Enterprise Edition. To learn more about PowerBuilder, visit the Powersoft
Web site at www.powersoft.com.
|
Like Developer/2000 and Power Objects, PowerBuilder uses a scripting language
named PowerScript for event-driven programming. Each object has a set of predefined events
for which you can write a script. This script is executed when the event is triggered by an
external eventfor example, a user pressing Deleteor by another object's script. In addition,
you can define additional events for an object and invoke PowerBuilder's comprehensive set
of built-in functions from an event script.
Today, you will look at three specific areas:
- Defining a database profile for an Oracle database
- Creating a DataWindow for an Oracle table or join
- Handling Oracle errors
The first phase in using PowerBuilder with an Oracle database is setting up a database profile.
- Open the PowerBuilder application in which you want to add the database profile.
- To add a database profile, click on the DB Profile icon on the toolbar (it looks
like four green cylinders). A window will appear, displaying the existing
database profiles (see Figure 22.1).
- Click on New to add a database profile. The Database Profile Setup window
will appear.
- Enter Flugle in the Profile Name field (see Figure 22.2).
- In the DBMS field, select the current version of your database. This example
shows O72 ORACLE v7.2 from the dropdown list (see Figure 22.2).
- Click on More to specify the other fields for the Oracle database profile.
Page 581
Figure 22.1.
The Database Profiles
window displays
existing database
profiles.
Figure 22.2.
Specifying the Profile
Name and DBMS for
the new database
profile.
NOTE
|
If you do not see your current version in the dropdown list, you
may need to reinstall some components. During the installation
of PowerBuilder Enterprise Edition, you can select Typical or
Custom installation options. The Typical installation option will not install
the current version's native database driver. If you are using Windows
95 or Windows NT, you must be using SQL*Net V2.2 or above, and
you must install the Oracle 7.x or higher's PowerBuilder native
database driver.
|
Page 582
- If you are connecting to an Oracle server, enter the database alias that you use
in the Server Name field. If you are using Personal Oracle, leave this field blank.
- In Login ID, enter the Oracle username that you want to use for accessing
the database.
- In Login Password, enter the password for the Oracle user, as displayed in
Figure 22.3.
Figure 22.3.
Specifying the Server
Name, Login ID, and
Login Password for
the new database
profile.
- Click OK. PowerBuilder will create the database profile and display it in the list
of available profiles (see Figure 22.4).
Figure 22.4.
The new database profile is displayed in the list of
database profiles.
- After you've created the new database profile, you will see it displayed in the list
of available database profiles. To use the database profile, select it and click OK.
Page 583
NOTE
|
The first time you create a database profile for an Oracle
database, PowerBuilder tries to create a repositorya set of five tables that
are used to store additional information about each table's columns,
such as format or validation. The tables are PBCATCOL,
PBCATEDT, PBCATFMT, PBCATTBL, and PBCATVLD.
By default, PowerBuilder tries to create these tables in the
Oracle SYSTEM account. Normally, PowerBuilder will return an Oracle
error ORA-01031, insufficient privileges, if the Oracle user specified
in Login ID doesn't have the privilege to create a table in the
SYSTEM account.
There are a couple ways to create the repository if it doesn't
already exist. You can create the new database profile and specify
SYSTEM for Login ID and the SYSTEM password for Login Password.
From SQL*Plus or SQL Worksheet, you then can grant the
SELECT, INSERT, UPDATE, and DELETE privileges on the five repository tables to the
Oracle user that you want to specify in Login ID.
|
Creating a DataWindow
To create a new DataWindow, follow these steps:
- Click the Datawindow button on the toolbar (it looks like a form and is the
ninth button from the left). A window, labeled Select DataWindow, will appear,
displaying all the existing DataWindows for the application (see Figure 22.5).
- Click New to create a new DataWindow. You will then see the New
Datawindow window.
- You must make two choices for the New DataWindowits data source
and presentation style. Choose SQL Select for the data source and Tabular for
the presentation style (see Figure 22.6).
- Click OK.
Another window, labeled Select Tables, will appear. By default, this window will display
all the tables that are accessible to the Oracle user associated with the current database
profile. This list of tables will include tables owned by other Oracle users. Scroll down to
the STUDENT table and click Open (see Figure 22.7).
Previous | Table of Contents | Next
|
Используются технологии
uCoz