Oracle Pro*C/C++(TM) Getting Started for Windows Platforms
Release 8.0
A53634-01

Library

Product

Contents

Index


Prev Next

2
Using Pro*C/C++

This chapter explains how to create and precompile a project. It also describes the Pro*C/C++ graphical interface, which you use to execute commands with Windows menus and icons or with keyboard equivalents.

This chapter includes:

Oracle Directory Structure

Installing Oracle software creates a directory structure on your hard drive for your Oracle products. A main directory-the Oracle home directory-holds the Oracle subdirectories and files that are necessary to run Pro*C/C++.

Note:

The following diagram illustrates the directory structure for Windows NT. This directory structure is similar for Windows 95.  

In this example, the default Oracle home directory for Windows NT is \ORANT.

The subdirectories in \ORANT hold the Pro*C/C++ executable files and the library files.

The letters nn represent the version of the product installed. For example, if you have already installed Pro*C/C++ Version 3.0, you have a \PRO30 subdirectory under \ORANT. If you now install Pro*C/C++ version 8.0, Oracle Installer adds a \PRO80 subdirectory.

Oracle Home Subdirectories

The subdirectories in the Oracle home directory, include:

\RDBMSnn  

 

Contains Oracle8 server message, resource, README, and database files.  

\BIN  

 

Holds executable programs batch files, and the dynamic link libraries (DLLs).  

\DBS  

 

Holds the files for Toolkit II and message files for products created for the Oracle Installer.  

\ORAINST  

 

Holds the Oracle Installer utilities and other files.  

\PLSQLnn  

 

Contains message files, SQL scripts, and demonstration files for PL/SQL.  

\PROnn  

 

Holds subdirectory that contains files and subdirectories for Pro*C/C++.  

\OCInn  

 

Holds executable programs and files for Oracle Call Interface.  

Product Subdirectories

Based on the supported products you choose to install, Oracle Installer also creates the appropriate product subdirectory. For example, when you install Pro*C/C++, Release 8.0, the Oracle Installer creates the \PRO80 subdirectory, which contains files and subdirectories for Pro*C/C++.

Under the \PRO80 subdirectory, you find the following subdirectories:

\C  

 

Contains SAMPLES and INCLUDE subdirectories.  

\C\INCLUDE  

 

Contains header files for Pro*C/C++.  

\C\SAMPLES  

 

Contains subdirectories for each sample program.  

\LIB  

 

Contains the libraries used by Pro*C/C++.  

\LIB\MSVC  

 

Contains Pro*C/C++ libraries compatible with Microsoft Visual C++ 5.0.  

\LIB\BORLAND  

 

Contains Pro*C/C++ libraries compatible with Borland C++ 5.0.  

Sample Programs

The Pro*C/C++ installation procedure copies a set of 32-bit sample programs and their corresponding .DSP and .IDE files into the \PRO80\C\SAMPLES (for Windows NT and Windows 95) directory. Samples can be found in their corresponding subdirectories. Oracle recommends that you build and run these sample programs to verify that Pro*C/C++ has been installed successfully and operates correctly.

Additional Information:

See "Building and Running Sample Programs" in Chapter 3.  

Using the Graphical Interface

Before you follow the instructions for creating and precompiling a Pro*C/C++ project, you may wish to familiarize yourself with the basic commands, dialog boxes, menus, and buttons for the Pro*C/C++ graphical interface.

Start the Pro*C/C++ Application Window by clicking on its icon in the Oracle for Windows NT program group or typing procui80.exe at the command line.

Pro*C/C++ Application Window

Use the Pro*C/C++ Application Window to create a Pro*C/C++ project. This window contains five elements.

Title Bar

Displays Pro*C/C++ and the name of your precompile project. If you have not assigned a name to the current project, the word "Untitled" appears instead.

Menu Bar

When you select an item on the Menu bar, a list box of command options drops down. The Menu bar contains the following menus:

File  

Contains command options that you can use to begin a new project, open a saved project, save a project, specify a connect string to an Oracle database, or exit the current session. (See Toolbar)  

Edit  

Contains selection to add or delete files from the project. The options selection enables you to change options for the selected files.  

Preferences  

Contains two selection options to choose the manner, in which a name is assigned to the output file.  

Help  

Provides the version number of Pro*C/C++ that is currently being used.  

Toolbar

Enables you to execute commands without navigating through menus or typing on the keyboard.

Element   Explanation  

New  

Create a new project file.  

Open  

Opens an existing project file.  

Save  

Saves the active project file to disk.  

Add  

Adds a file to the precompile list.

 

Delete  

Delete files from the precompile list.

 

Options  

Displays or changes default precompile options. The Options dialog box appears.  

Precompile  

If you want to precompile one or more (but not all) the input files listed, select the file(s) to be precompiled, then choose Precompile.  

Pro*C/C++ Application Window Example

The Pro*C/C++ Application Window displays information about the precompilation status.

Element   Explanation  

Precompilation Status Bar  

Shows the results of your precompilation. Look for one of the status icons in the precompile status bar once the precompile process is complete.  

Double clicking on the status icon opens the Precompilation Status dialog message box. This message box provides detailed information on the status of the precompiled file.

Element   Explanation  

Input File  

Shows the names of the input (.pc) files to be precompiled.  

Output File  

Shows the output file names of the precompiled files.  

Options  

Displays precompile options that are different from the default options.  

Creating and Precompiling a Pro*C/C++ Project

To create and compile a project, you must:

  1. Access the Pro*C/C++ application and open a Pro*C/C++ project file (.PRE).
  2. Set the default output filename option (optional).
  3. Create a list of files to be precompiled.
  4. Delete files from the list (optional).
  5. Set precompile options (optional).
  6. Specify a database connect string (optional).
  7. Precompile.
  8. Check the results. Fix any errors

The Pro*C/C++ Application Window opens only one project at one time. A project may consist of one or more precompilable files.

Step 1. Open a project

To begin using Pro*C/C++, select the Pro*C/C++ icon from the Oracle for Windows NT programs menu. The Pro*C/C++ Application Window appears.

Create a new project by clicking the New button. To open an existing project, click the Open button.

Step 2. Set the default output file name option (optional)

Use the Preferences menu to choose the manner in which a name is assigned to the output file. The setting only affects to-be-added input files. An existing output file name will not be changed. However, you can change an output file name manually by double-clicking on the output file and entering a new name.

When you select the Default Output File Name toggle command, a checkmark 3 appears, and the system assigns a default output filename. In this case, the output file has the same name as the input file, except for the extension. For example, if you select winsam.pc from the Input File dialog box, the name in the Output File dialog box defaults to winsam.c (for C) and . winsam.cpp (for C++).

If you turn off the 3 Default Output File Name, the checkmark disappears. In this case, when you select an input file, the Output File dialog box appears.

Enter an output filename for each file selected. Once you select or enter a filename, it appears in the Output File dialog box.

Note:

To change the name of an Output file (or an Input File), double-click the filename in the Output File (or the Input File) on the information pane. The Output File (or Input File) dialog box appears. Replace the old filename with the new filename.  

Step 3. Create a list of input files

To create a list of files to be precompiled, do one of the following:

The Input File dialog box appears:

Select one or more files from the File Name list box. If the file you want resides in a different drive or directory, use the Drives and Directory list boxes to locate it, or enter the filename with the full path name in the File Name text field.

Select (or enter) the files, then click on the Open button in the Input File dialog box. All selected files appear in the Input File of the Pro*C/C++ Application Window.

Step 4. Delete files from the Input and Output File lists (optional)

To delete files from the precompile list, first select a file(s), then choose the Delete button (or equivalent). The highlighted file-both the input file name and the output file-disappears from the list. You can select and delete one or several files at a time.

Step 5. Set the precompile options (optional)

To set precompile options, highlight one or more files in the Input File list (this enables the Options button in the toolbar, and the Options item in the Edit menu), then do one of the following:

The Options dialog box appears:

Use this dialog box to specify options for precompiling a file. You can activate (or change) options in one of three ways:

Default options are in effect for all newly added files. When you change an option's default setting, a description of the change appears in the Option String edit field (at the bottom of the screen) and in the Options information window (in the Application dialog box).

Note:

The Parse option default setting is "none" and the Code option default setting is "ANSI_C".  

Some options are numeric. These fields accept integers between 0 and 999, although some options have valid ranges. Nonvalid characters (such as letters in a numeric field) do not appear in the Option String edit field. If you enter nonnumerical characters (or nothing) in a numeric edit field, default settings are restored when you exit that field.

Additional Information:

Four of the options are described in this section. For a description of the other options, see the Programmer's Guide to the Oracle Pro*C/C++ Precompiler.  

Include Directories

Use this field to enter INCLUDE path directories. If you want to enter more than one, separate each path with a semicolon, but do not have a space after the semicolon. This causes a separate "includes=" string to appear in front of each directory.

For samples that precompile with parse=partial or parse=full, an include path of C:\PROGRAM FILES\DEVSTUDIO\VC\INCLUDE has been added by default. If Microsoft Visual C++ has been installed at a different location or if Borland C++ is used, modify the Include Directories input field accordingly for the samples to precompile without errors.

Listing/Errors

To change the settings, which effect the format of the output list file that the precompiler writes to disk, click the Listing/Errors button. The Listing/Errors dialog box appears:

Use this dialog box to change the settings, such as the type of error information generated and the name of the list file, which effect the format of the output list file that the precompiler writes to disk.

Additional Information:

For more information, see the Programmer's Guide to the Oracle Pro*C/C++ Precompiler.  

After you set the options, choose OK to return to the Pro*C/C++ Application Window. Any option you changed from its default value appears as a command line string in the Options information pane.

Step 6. Specify a database connection information (optional)

If you selected semantic or full for the SQLCHECK option in the Options dialog box, you may need to specify a database connection information to the Oracle database. You do not need to connect to the Oracle database if every table referenced in a data manipulation statement or PL/SQL block is defined in a DECLARE TABLE statement.

After you return to the Pro*C /C++ Application Window, select Connect from the File menu. The Connect dialog box appears.

Use this dialog box to specify a database connection information prior to precompiling (no database connect is performed at this time). Only one database connection information can be specified for all files requiring semantic or full SQLCHECKing.

The Connect dialog box appears automatically at precompile time if you have not previously responded. Type the username, the password, and the connect string (not required for local database). Then choose OK.

If you want to save the Connect information between Pro*C/C++ sessions, select the Save Connect String to Disk check box. If you do not select the check box, no fields are stored, and you must enter this information each time you precompile with Pro*C/C++.

Step 7. Precompile

You can precompile any number of files in the list. To precompile one or more files, first select the appropriate files from the list, then choose Precompile. To precompile the selected files, do one of the following:

When precompiling is completed, the message in the dialog box says "Precompiling Finished", and the Cancel button changes to OK. Choose OK to continue.

Note:

Although Cancel does not interrupt the precompile for a file already in process, it does halt the precompile chain for remaining files.  

Step 8. Check the results

Precompiling can result in success, success with warning(s), or failure. When precompiling is finished, check the Precompilation Status Bar. If all your files precompiled successfully, you see only green checkmarks. A yellow checkmark means success with warnings, while a red checkmark means that there are precompilation errors.

Close the program by selecting Exit from the File menu. (You are prompted to save your project if it changed in any way.)

Suggestion:

If you want to keep an original file, as well as a version of the file with your changes, select the Save As command. The Save command overwrites the prior version.  

Step 9. Fix errors

Double-click the yellow (or the red) checkmark to display the Precompilation Status list box, which lists warning messages or reasons why the precompilation failed:

Switch to your development environment, or your own editor, to fix the problems. After you correct the errors, precompile again.

Precompiling on Command Line

If you perform the majority of your programming tasks from the command line, it is recommended that you continue to run Pro*C/C++ from the command line as well. Use the following syntax to precompile an application with Pro*C/C++:

C:\>PROC INAME=filename.PC 

where, filename.pc is the name of the source file. The precompiler then generates a filename.c, which can be compiled by your C compiler.

If the source file is not within your current working directory, include the file's full path after the INAME argument.

Header Files

Pro*C/C++ Standard Header Files are installed in the \PRO80\C\INCLUDE directory under your Oracle home directory.

Additional Information:

For more information on each standard header file, see the Programmer's Guide to the Oracle Pro*C/C++ Precompiler.  

ORACA.H

Consist of extended set of diagnostic tools for runtime errors and status changes. ORACA handles Oracle communications. Note, that using the ORACA adds to runtime overhead.

SQL2OCI.H

Consists of SQLLIB functions that enable OCI environment handle and OCI service context to be obtained in a Pro*C/C++ program.

SQLAPR.H

Consists of ANSI prototypes for externalized functions that can be used in conjunction with OCI.

SQLCA.H

Consists of the host language data structure. Oracle updates the SQLCA after every executable SQL statement (values are undefined after a declarative statement). By checking Oracle return codes stored in the SQLCA, your program can determine the outcome of an SQL statement.

SQLCPR.H

Provides platform-specific, ANSI prototypes for SQLLIB functions that are generated by Pro*C/C++. By default, Pro*C/C++ does not support full-function prototyping of SQL programming calls. If you need this feature, include SQLCPR.H before any EXEC SQL statements in your Oracle database application source file.

SQLDA.H

Consists of the host program data structure that holds descriptions of select-list items or input host variables. SQLDA files differ among host languages and operating systems.

SQLKPR.H

Consists of K&R prototypes for externalized functions that can be used in conjunction with OCI.

PL/SQL Option

If you are using embedded PL/SQL blocks, you must include the SQLCHECK parameter in the precompiling command, specifying the FULL option, as SQLCHECK=FULL. This parameter checks the syntax or semantics of embedded SQL statements and PL/SQL blocks.

Additional Information:

For more information, see the Programmer's Guide to the Oracle Pro*C/C++ Precompiler.  




Prev

Next
Oracle
Copyright © 1997 Oracle Corporation.
All Rights Reserved.

Library

Product

Contents

Index