Page 1062
You can embed OCI in a precompiled host program by following these steps:
The LDA data structures and function calls are language specific. Consult the Programmer's Guide to the Oracle Call Interface for complete information about this product.
The Oracle SQL*Module compiler (version 1.1 was released with Oracle7.2) provides access to ANSI standard module language files and Oracle stored PL/SQL procedures through native function calls in Ada, C, and C++. It is 100 percent compliant with entry-level SQL92. It accepts
Programmer productivity is improved when you let SQL experts write database code and C experts write C code. SQL*Module works by converting the SQL modules into stored procedures, producing specification files that are included in 3GL source files. After you add the appropriate Oracle runtime libraries to the project build utility, the compile and link process works as usual. Security is enhanced by granting users EXECUTE privileges on the stored procedures, instead of giving direct access to data. Stored procedures also improve performance because you can compile them once and share them via the Oracle7 shared SQL cache.
Oracle precompilers provide an
Page 1063
Page 1064
Page 1065
Page 1066
PowerSoft Corporation's PowerBuilder is a highly object-oriented visual development tool. It is used primarily for Microsoft Windows development, although it aspires to support other platforms. PowerBuilder ships with the desktop version of the Watcom SQL database engine, which (until the release of Personal Oracle7) was widely
The PowerBuilder object model is extended to its unusual development environment, which features separate "
The primary focus of this chapter is PowerBuilder's support for the development of database applications. The closing sections of the chapter present a brief overview of some of the more significant features of PowerBuilder and
Additional configuration is required to prepare an ODBC data source for use in PowerBuilder. The proprietary interface driver, PBOR7040.DLL, is required to connect to Oracle. Unfortunately, this driver does not ship with the desktop version of PowerBuilder. It is available with the Enterprise edition and PowerBuilder Team/ODBC, which also include a number of additional toolkits.
After installing SQL*Net and the PowerBuilder Oracle interface, install the Oracle ODBC driver and configure a data source using the ODBC Administration utility (typically installed as a Windows Control Panel applet). Next, you should create a PowerBuilder database profile, using the database painter. From the Database Painter, select Setup from the Connect option cascade of the File menu to open the Database Profile Setup dialog box as
Figure 46.1.
The Database Profile
Setup dialog box is used
to configure a
PowerBuilder
connection for Oracle.
In the Profile Name field, enter a description to be used for the Oracle profile. This value is simply used as a name for the profile. The DBMS field should be set to OR7 for version 7 of Oracle and OR8 for Oracle8. The DBMS field is used by PowerBuilder to determine which proprietary interface driver to use.
Page 1067
Oracle connections, and you can leave them blank. The check box in the lower left can be used to force PowerBuilder to prompt for connection information when using the Profile to connect to the database. If this box is not checked, PowerBuilder will not prompt for this information if it is supplied. This should be left blank so that the information can be supplied at runtime using a login window, rather than the generic dialog box. Click on the More button in the lower right-hand corner to display more options. The Server Name field requires a SQL*Net connect string for version 1 of SQL*Net, or a service name for SQL*Net version 2. For example, if TCP/IP is being used to connect to the database using SQL*Net version 1, the Server Name might be entered as
{% if main.adsdop %}{% include 'adsenceinline.tpl' %}{% endif %}T:ORACLE_SERVER:ORACLE7
The Login ID and Login Password fields should not be supplied in most cases, as storing these values would be considered a security risk. These parameters are used for the Oracle ID and password, and they can be supplied at runtime. DBPARM is used to store additional
Figure 46.2.
This Database Profile
Setup dialog box is an
example of the
parameters required to
connect to Oracle.
Additional preparation is required on the Oracle server to prepare Oracle for certain PowerBuilder features. The SQL script supplied with the Oracle interface, PBORCAT.SQL, should be run by the DBA. This creates objects in Oracle that will be accessed by PowerBuilder to provide additional features that would
Page 1068
At design time, you can use the Database Profile to connect to Oracle by selecting Prompt from the Connect option of the File menu of the database painter, and selecting the name of the Oracle profile from the drop-down list in the Data Sources dialog box.
At runtime, PowerBuilder uses a transaction object to connect to the data source. The default transaction object is named
Listing 46.1. This script sets transaction object values and connects to the database.
transaction sqlca_sps;
sqlca_sps = create transaction;
sqlca_sps.DBMS = "OR7"
sqlca_sps.userid = "scotty"
sqlca_sps.dbpass = "tiger"
sqlca_sps.servername = "T:ORA_SRV:ORACLE7"
sqlca_sps.dbparm = "PBDBMS=1"
connect using sqlca_sps;
if sqlca_sps.sqlcode <> 0 then
MessageBox ("Database Error", sqlca_sps.sqlerrtext)
HALT close
end if
Listing 46.1 illustrates the use of two of the additional properties of the transaction object, sqlcode and sqlerrtext. If the sqlcode property is
The DataWindow is the primary means of retrieving result sets in PowerBuilder.
When the DataWindow painter is started, a Select DataWindow dialog box is presented. When the New command button is clicked, the data source and style for the new DataWindow must be selected. The style options include Free-Form (for data entry forms), Grid, Tabular, and Graph, among others. Of the data source options, SQL Select and Stored Procedure are the most significant.