?
Solved

Oracle Pro C

Posted on 2002-07-02
2
Medium Priority
?
1,009 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

719 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