User`s guide

Developing an Oracle Database/openUTM Application
openUTM Product Set 8-7
8.4.2 Using Precompilers with openUTM
You can choose from two options when interfacing with precompilers:
Using precompilers with the default database
Using precompilers with a named database
You should run all precompiler programs with the option
release_cursor
set to
no
.
Precompiler programs may be written in C or COBOL. In the following examples, the
precompiler Pro*C is used.
8.4.2.1 Using Pro*C with the Default Database
To interface to Pro*C with the default database, ensure that the
DB
=
db_name
field used
in the open string is not present. The absence of this field indicates the default
connection as defined in the
ORAENV
file, and only one default connection is allowed for
each process.
The following is an example of an open string identifying a default Pro*C connection:
Oracle_XA+SqlNet=MADRID_FINANCE+Acc=P/scott/tiger+SesTm=0
Here,
DB
=
db_name
is absent, indicating an empty database identifier string.
The following is the syntax of a select statement:
EXEC SQL SELECT ENAME FROM EMP;
8.4.2.2 Using Pro*C with a Named Database
To interface to Pro*C with a named database, include the
DB
=
db_name
field in the open
string. Any database you refer to must reference the same
db_name
specified in the
corresponding open string.
An application may include the default database, as well as one or more named
databases, as shown in the following examples.
For example, suppose you want to update an employee's salary in one database, the
department number
deptno
in another, and the manager information in a third
database. You would configure the following open strings in the transaction manager:
Oracle_XA+SqlNet=MADRID_FINANCE1+Acc=P/scott/tiger+SesTm=0
Oracle_XA+DB=MANAGERS+SqlNet=MADRID_FINANCE2+
Acc=P/scott/tiger+SesTm=0
Oracle_XA+DB=PAYROLL+SqlNet=MADRID_FINANCE3+
Acc=P/scott/tiger+SesTm=0
There is no
DB
=
db_name
field in the first open string.
In the application program, you would enter declarations such as:
EXEC SQL DECLARE PAYROLL DATABASE;
EXEC SQL DECLARE MANAGERS DATABASE;
Again, the default connection corresponding to the first open string that does not
contain the
db_name
field, does not require a declaration.
When doing the update, enter statements similar to the following:
EXEC SQL AT PAYROLL update emp set sal=4500 where empno=7788;
EXEC SQL AT MANAGERS update emp set mgr=7566 where empno=7788;
EXEC SQL update emp set deptno=30 where empno=7788;
There is no AT clause in the last statement because it refers to the default database.