Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Problem with Pro*C Precompiler...

Re: Problem with Pro*C Precompiler...

From: Harald Maier <maierh_at_myself.com>
Date: Sat, 25 Oct 2003 08:47:52 +0200
Message-ID: <m3u15xolt3.fsf@ate.maierh>


"Jens Engel" <Jens.Engel_at_stadt-mh.de> writes:

> Hi...
>
> Is there any Pro*C Syntax for "EXEC SQL IFDEF XXX" in Oracle, that
> sticks to ANSI standard? I only know "EXEC ORACLE IFDEF XXX", but
> that is not ANSI standard and so my Informix precompiler gives an
> error message when trying to precompile my ec-file. (It has to be
> precompiled with Oracle AND Informix, so I need a syntax, that is
> understood by both of them...) Informix uses ANSI standard ("EXEC
> SQL..."), Oracle doesnīt, thatīs my problem.

Pro*C itself uses a C-Preprocessor so you can use inside a EXEC SQL statement the most valid C-Preprocessor directives. See herefor 'The C Preprocessor' in the 'Pro*C/C++ Precompiler Programmer's Guide' (A97269-01).

,----

| EXEC SQL BEGIN DECLARE SECTION;
| 
| #ifdef ORA_PROC
|   ... Oracle Pro*C relevant code
| #esle
|   ... Code that is not processed by Oracle Pro*C
| #endif
| 
| #define ABC_LEN 20
| 
| VARCHAR abc[ABC_LEN];
| 
| EXEC SQL END DECLARE SECTION;

`----

As far as I know this works only inside the EXEC SQL DECLARE section. It will not work in this example:

,----

| exec sql
|   #ifdef ORA_PROC
|     ... A Oracle specific statement
|   #else
|     ... A Informix specific statement
|   #endif
|   ;

`----

I would still use the EXEC ORACLE IFDEF directive. If Informix understands the EXEC SQL IFDEF directive then you can modify the code with sed or perl before you process the file with the Informix precompiler. Another option would be that you preprocess the files with some logic by yourself. But then you must ensure that the cpp generated #line directives are valid after processing so that you are still in the position to debug your code. Personally, I think this is not so easy.

Harald Received on Sat Oct 25 2003 - 01:47:52 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US