Pro*C/C++ Getting Started for Windows Platforms Go to Product Documentation Library
Library
Go to books for this product
Product
Go to Contents for this book
Contents
Go to Index
Index



Go to previous file in sequence Go to next file in sequence

Using Pro*C/C++



Summary of Precompile Steps

The Pro*C/C++ precompiler takes SQL statements embedded in your C/C++ program and converts them to standard C/C++ code. When you successfully precompile this code, the result is a C/C++ program that you can compile and use to build applications that access an Oracle database.

To create and run a precompile project, you must:

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


  10. Additional Information See "Creating and Running a Precompile Project" in this chapter for more detailed information.

Using the Graphical Interface

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

Application Dialog Box

The Pro*C/C++ Application dialog box 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.

Toolbar

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

Element Explanation
New To create a new project file, choose the "new sheet" icon (or choose New Project from the File menu, or press Ctrl+N).
Open To open an existing project file, choose the "opening folder" icon (or choose Open Project from the File menu, or press Ctrl+O). The File Open dialog box displays a list of project files.
Save To save the active project file to disk, choose the "diskette" icon (or choose Save or Save As from the File menu, or press Ctrl+S).
Add To add a file to the precompile list, select the "+" icon (or choose Add from the Edit menu, or press Ctrl+A). The Input File dialog box displays files with .pc extensions. Select one or more files and choose OK. The filename(s) appears in the Input File window.
Delete To delete files from the precompile list, use the mouse to highlight the files in the Input File window, then select the "-" icon (or choose Delete from the Edit menu, or press Ctrl+D).
Options To display or change default precompile options, choose the "checklist" icon (or choose Options from the Edit menu, or press Ctrl+P). The Options dialog box appears.
Run If you want to precompile one or more (but not all) the input files listed, select the file(s) to be precompiled, then choose Run (or choose Run from the File menu, or press Ctrl+R).

Information Windows

Displays information about the precompilation status. You use this screen to control and monitor the precompile.

Element Explanation
Precompile 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 click 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 Running a Precompile Project

The Pro*C/C++ application opens only one project at one time. A project consists of one or more precompilable files.

Note This section is also applicable for Windows NT.

To begin using Pro*C/C++, select the Pro*C/C++ icon from the Windows 95 Programs menu. The Pro*C/C++ Application dialog box appears.

Step 1. Open a project

To create a new project, click 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 check mark 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 check mark 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 on the Information Window.

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 Window. 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 box.

Select the files you select (or enter), then click on the Open button in the Input File dialog box. All selected files appear in the Input File of the Information 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)

Target Operating System

The Target Operating System is WIN32.

Note When using WIN32, Pro*C/C++ generated code is always reentrant.

To open the Options dialog box and 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. Invalid characters (such as letters in a numeric field) do not appear in the Option String edit field. If you enter other than numeric 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.

Reentrant (Windows 16-bit only)

To create a reentrant DLL under Windows from the Pro*C generated code, use the Reentrant option.

Far Call (Windows 16-bit only)

Use the Far Call option when using the medium memory model to compile the code generated by Pro*C.

Include

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.

Listing/Errors

To change the settings, which affect 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 affect 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 Application dialog box. Any option you changed from its default value appears as a command line string in the Options information window.

Step 6. Specify a database connection information (optional)

If you selected semantic or full sqlchecking 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 Application dialog box, 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). 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++.

Note You need SQL*Net (32-bit) for the target operating system. Therefore, use registry for declaring variables like LOCAL, REMOTE, and the like.

warning

If you do store this information, your password is also saved and is available to anyone who has access to your PC.

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 Run. A dialog box appears during precompiling to show the progress.

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 Precompile Status Bar. If all your files precompiled successfully, you see only green check marks.

Exit 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.

A yellow check mark means success with warnings, a red "X" in the Precompile Status Bar means that there are errors in the precompile.

Step 9. Fix errors

Double-click the yellow check mark or red "X" to display the Precompilation Status list box, which lists warning messages or reasons why the precompile failed.

Switch to your development environment, or your own editor, to fix the problems. After you correct the errors, run the 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 

In this command line, 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 \PRO30\C\INCLUDE directory under your Oracle home directory.

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

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.

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

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.

Additional Information For more information, 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.

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

SQLPROTO.H

Consists of full ANSI function prototypes for routines 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 SQLPROTO as the first line of code in your Oracle database application's source files.

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.



Go to previous file in sequence Go to next file in sequence
Prev Next
Oracle
Copyright © 1996 Oracle Corporation.
All Rights Reserved.
Go to Product Documentation Library
Library
Go to books for this product
Product
Go to Contents for this book
Contents
Go to Index
Index