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

Home -> Community -> Usenet -> c.d.o.tools -> Re: Pro*C: error PCC-S-02201 while compiling

Re: Pro*C: error PCC-S-02201 while compiling

From: Ed prochak <ed.prochak_at_magicinterface.com>
Date: 23 Sep 2004 10:25:23 -0700
Message-ID: <4b5394b2.0409230925.27780bff@posting.google.com>


"Andrea Laforgia" <x_at_x.x> wrote in message news:<cis6i4$5uf$1_at_newsread.albacom.net>...
> I'm using Oracle9i and trying to compile a .pc file into a .c file.
> The code is the following:
>
> #include <stdio.h>
> #include <stdlib.h>
> #include <math.h>
> #include <string.h>
>
> #define SQLCODE sqlca.sqlcode
> #define SQLNULL 1403
> #define SQLNONE -1405
> #define SQLPRES -1
> #define SQLOK 0
> #define SQLKO 1
>
> EXEC SQL INCLUDE SQLCA;
>
> typedef struct {
> char MRN[19];
> int SEQUENCE;
> int OFFICIAL_VERSION;
> } MYSTRUCT;
>
> void myfunc()
> {
> EXEC SQL BEGIN DECLARE SECTION;
> MYSTRUCT A;
> EXEC SQL END DECLARE SECTION;
>
> EXEC SQL SELECT WGTTRS_MRN,
> WGTTRS_SEQUENCE
> INTO :A.MRN,
> :A.SEQUENCE
> FROM WGTTRS
> WHERE WGTTRS_MRN = :A.MRN
> AND WGTTRS_OFFICIAL_VERSIONE = :A.OFFICIAL_VERSION;
> }
>
> while compiling it:
> D:\Myfolder>proc iname=andrea.pc
>
> I get the following errors:
> Pro*C/C++: Release 9.0.1.1.1 - Production on Mer Set 22 17:29:00 2004
>
> (c) Copyright 2001 Oracle Corporation. All rights reserved.
>
> System default option values taken from:
> D:\oracle\ora90\precomp\admin\pcscfg.cfg
>
> Error at line 26, column 6 in file andrea.pc:
> MYSTRUCT A;
> .....1
> PCC-S-02201, Encountered the symbol "MYSTRUCT" when expecting one of the
> following:
>
> auto, char, const, double, enum, extern, float, int, long,
> ulong_varchar, OCIBFileLocator OCIBlobLocator,
> OCIClobLocator, OCIDateTime, OCIExtProcContext, OCIInterval,
> OCIRowid, OCIDate, OCINumber, OCIRaw, OCIString, register,
> short, signed, sql_context, sql_cursor, static, struct,
> typedef, union, unsigned, utext, uvarchar, varchar, void,
> volatile, a typedef name, a precompiled header, exec oracle,
> exec oracle begin, exec, exec sql, exec sql begin,
> exec sql end, exec sql type, exec sql var, exec sql include,
> The symbol "enum," was substituted for "MYSTRUCT" to continue.
>
> Error at line 0, column 0 in file andrea.pc
> PCC-F-02102, Fatal error while doing C preprocessing
>
> It seems like the precompiler is unable to recognize the type MYSTRUCT that
> I defined.
>
> I tried to change the code in the following:
>
> #include <stdio.h>
> #include <stdlib.h>
> #include <math.h>
> #include <string.h>
>
> #define SQLCODE sqlca.sqlcode
> #define SQLNULL 1403
> #define SQLNONE -1405
> #define SQLPRES -1
> #define SQLOK 0
> #define SQLKO 1
>
> EXEC SQL INCLUDE SQLCA;
>
> void myfunc()
> {
> EXEC SQL BEGIN DECLARE SECTION;
> char MRN[19];
> int SEQUENCE;
> int OFFICIAL_VERSION;
> EXEC SQL END DECLARE SECTION;
>
> EXEC SQL SELECT WGTTRS_MRN,
> WGTTRS_SEQUENCE
> INTO :MRN,
> :SEQUENCE
> FROM WGTTRS
> WHERE WGTTRS_MRN = :MRN
> AND WGTTRS_OFFICIAL_VERSIONE = :OFFICIAL_VERSION;
> }
>
> ...and it compiles successfully!...
>
> The former is just a piece of code I made to simplify, I could not post the
> real code.
> How can I solve ?
>
> TIA
> Andrea

There is nothing to solve. The error message tells you, in a longwinded way, that structs are not supported. You will have to restructure (or maybe that should be DEstructure?) your code. There are Oracel type like VARCHAR that can be used which are structures, but user defined structures are not recognized. This is just a lowly precompiler after all.

Now there is an alternative. IIRC, you do not have to list all your variables in the DECLARE section before using them in a query. Something like this should work:

typedef struct {

         char MRN[19];
         int  SEQUENCE;
         int  OFFICIAL_VERSION;

 } MYSTRUCT;    void myfunc( int version_num, char *master_rec_name )  {   

      MYSTRUCT A;  

      A.OFFICIAL_VERSION = version_num ;
      strcpy ( A.MRN, master_rec_name );

      EXEC SQL SELECT
                      WGTTRS_SEQUENCE
               INTO  
                      :A.SEQUENCE
               FROM WGTTRS
               WHERE WGTTRS_MRN = :A.MRN
               AND WGTTRS_OFFICIAL_VERSIONE = :A.OFFICIAL_VERSION;
 }

Note: I removed the redundant A.MRN from the SELECT...INTO... clause since your WHERE CLAUSE uses it to identify the result.

So go review the manual. You'll do okay from here.

Ed. Received on Thu Sep 23 2004 - 12:25:23 CDT

Original text of this message

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