Pro*C/C++
Precompiler Getting Started
Release 8.1.5 for Windows NT and Windows 95/98 A68801-01 |
|
This chapter describes the sample programs that are provided
with Pro*C/C++ release 8.1.5 for Windows NT and Windows 95/98.
Specific topics discussed are:
The ORACLE_BASE\ORACLE_HOME\PRECOMP\DEMO\PROC
directory contains the following sample programs:
The following subsections describe the functionality of the
sample programs.
Demonstrates using ANSI dynamic SQL to process SQL statements
that are not known until runtime. This program is intended to demonstrate
the simplest (though not the most efficient) approach to using ANSI dynamic
SQL.
Demonstrates using ANSI dynamic SQL to process SQL statements
that are not known until runtime. This program uses the Oracle extensions
for batch processing and reference semantics.
Fetches census information for California counties. This
program demonstrates various ways to navigate through collection-typed
database columns.
Prompts the user for an employee number, then queries the
EMP table for the employee's name, salary, and commission. This program
uses indicator variables (in an indicator struct) to determine whether
the commission is NULL.
Retrieves the names of all employees in a given department
from the EMP table (dynamic SQL Method 3).
Finds all salespeople and prints their names and total earnings
(including commissions). This program is an example of C++ inheritance.
Declares and opens a ref cursor.
Fetches and adds crime records to the database based on the
person's Social Security number. This program demonstrates the mechanisms
for accessing and storing large objects (LOBs) to tables and manipulating
LOBs through the stored procedures available through the DBMS_LOB package.
Shows how to use threading in conjunction with precompilers.
The program creates as many sessions as there are threads.
Demonstrates navigational access to objects in the object
cache.
Demonstrates the use of objects. This program manipulates
the object types "person" and "address".
Demonstrates how to use ORACA to determine various performance
parameters at runtime.
Demonstrates the use of embedded PL/SQL blocks. This program
prompts you for an employee name that already resides in a database. It
then executes a PL/SQL block, which returns the results of four SELECT
statements.
Adds new employee records to the personnel database and checks
database integrity. The employee numbers in the database are automatically
selected using the current maximum employee number +10.
Logs on to an Oracle database, prompts the user for an employee
number, queries the database for the employee's name, salary, and commission,
and displays the result. The program continues until the user enters 0
as the employee number.
Logs on to an Oracle database, declares and opens a cursor,
fetches the names, salaries, and commissions of all salespeople, displays
the results, and closes the cursor.
Logs on to an Oracle database, declares and opens a cursor,
fetches in batches using arrays, and prints the results using the print_rows()
function.
Demonstrates the use of type equivalencing using the LONG
VARRAW external datatype.
Prompts the user for an account number and a debit amount.
The program verifies that the account number is valid and that there are
sufficient funds to cover the withdrawal before it debits the account.
This program shows the use of embedded SQL.
Creates a table, inserts a row, commits the insert, and drops
the table (dynamic SQL Method 1).
Inserts two rows into the EMP table and deletes them (dynamic
SQL Method 2).
Retrieves the names of all employees in a given department
from the EMP table (dynamic SQL Method 3).
Connects to an Oracle database using the SCOTT/TIGER account.
The program declares several host arrays and calls a PL/SQL stored procedure
(GET_EMPLOYEES in the CALLDEMO package). The PL/SQL procedure returns up
to ASIZE values. The program keeps calling GET_EMPLOYEES, getting ASIZE
arrays each time, and printing the values, until all rows have been retrieved.
Connects to an Oracle database using your user name and password
and prompts for a SQL statement. You can enter any legal SQL statement,
but you must use regular SQL syntax, not embedded SQL. Your statement is
processed. If the statement is a query, the rows fetched are displayed
(dynamic SQL Method 4).
Fetches from the EMP table, using a cursor variable. The
cursor is opened in the stored PL/SQL procedure open_cur, in the
EMP_DEMO_PKG package.
Demonstrates how to do array fetches using dynamic SQL Method
4.
Demonstrates how you can use the sqlvcp() function
to determine the actual size of a VARCHAR struct. The size is then used
as an offset to increment a pointer that steps through an array of VARCHARs.
This program also demonstrates how to use the SQLStmtGetText()
function to retrieve the text of the last SQL statement that was executed.
Adds new employee records to the personnel database and checks
database integrity. You can enter as many employee names as you want and
perform the SQL commands by selecting the appropriate buttons in the Employee
Record dialog box. This is a GUI version of the SAMPLE program.
To build the sample tables:
C:\> SQLPLUS
Enter user-name: SCOTT/TIGER
SQL> @ORACLE_BASE\ORACLE_HOME\DBS\DEMOBLD.SQL;
Microsoft Visual C++ 6.0 project files have an extension
of .DSP.
Additional
Information:
See Appendix A for more information about integrating Pro*C/C++ into Microsoft Visual C++. See Chapter 20 of the Pro*C/C++ Precompiler Programmer's Guide for more information about the Object Type Translator. |
To build a sample program:
Note: All of the sample programs were created with C:\ORACLE\ORA81 as the default drive. |
|
![]() Copyright © 1999 Oracle Corporation. All Rights Reserved. |
|