Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Oracle Pro C

Posted on 2002-07-02
2
Medium Priority
?
1,015 Views
Last Modified: 2009-12-16
Can someone tell a (Windows Based) Visual Basic Programmer the basics about how to compile and run an Oracle Pro C program on a Compaq Unix machine. I keep hearing something about a "Makefile" and pathing out my header files.....I was told the compiler is installed and have a source code file (I didn't write it..)
As usual, Boss wants something quick, no time to read the manual..

and Yes, I am out of my element here,...to say the least..

I appreciate any help...Thank you.
0
Comment
Question by:GeekMan
2 Comments
 
LVL 3

Accepted Solution

by:
p_yaroslav earned 400 total points
ID: 7125338
Hi!

How does one compile a PRO*C program?
You can study the sample makefile provided by Oracle and construct your own, but it would probably be better to just use "make" to precompile and then compile your program in one step. Look at this Unix examples:
Oracle7:

  make -f $ORACLE_HOME/precomp/demo/proc/proc.mk build EXE=myprog OBJS=myprog.o

Oracle8:

  make -f $ORACLE_HOME/precomp/demo/proc/demo_proc.mk build EXE=myprog OBJS=myprog.o

NOTE: OBJS and EXE has to be entered in caps!!!

How can I tell Pro*C what directory my header files are in?
Is there some way to tell the Pro*C preprocessor to search other directories for include (*.h) files, similar to the C compiler switch "-I"? I am hoping to avoid having to change all of my #include statements...
As documented in the Pro*C manual (in the chapter called "Running the Precompiler") there is an INCLUDE flag that can be used for this. Look at this example:


  proc iname=inputfile.pc include=directory1 include=directory2...

What is an indicator variable and why should I use it?
Indicator variables are used to explicitly handle NULL values. When you SELECT or FETCH a NULL value into a host variable/array an "ORA-01405: fetched column values is NULL" run-time error will result.
This behaviour was introduced with Oracle7 when you recompiled your programs with the DBMS=V7 (the default) precompiler option.

One workaround for this is to use the NVL() function to prevent the selection of NULL values.

Example:


  EXEC SQL SELECT ENAME, SAL, COMM
           INTO   :emp_name, :emp_sal, :emp_comm:comm_indicator
           FROM   emp;
  if (comm_indicator == -1)
      pay = emp_sal;
  else
      pay = emp_sal + emp_comm;

How does one execute PL/SQL code from Pro*C?
Look at this example:
       EXEC SQL EXECUTE
            begin
              dbms_application_info.set_client_info('My C Program with embedded PL/SQL');
            end;
       END-EXEC;


Hope it helps!
Yaroslav
0
 

Author Comment

by:GeekMan
ID: 7159694
Thank you, sorry I took so long to accept....
0

Featured Post

NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
Working with Network Access Control Lists in Oracle 11g (part 2) Part 1: http://www.e-e.com/A_8429.html Previously, I introduced the basics of network ACL's including how to create, delete and modify entries to allow and deny access.  For many…
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

783 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question