PDA

View Full Version : Pro*C: error PCC-S-02201 while compiling


x
09-22-2004, 07:43 AM
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

Bent Stigsen
09-23-2004, 04:00 AM
Andrea Laforgia wrote:

[snip]
It seems like the precompiler is unable to recognize the type MYSTRUCT that I defined.

yes, so if you wrap your typedefinition in a declare section, it should
help ;)

/Bent

Ed prochak
09-23-2004, 09:25 AM
"Andrea Laforgia" <x@x.x> wrote in message news:<cis6i4$5uf$1@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.

x
09-23-2004, 11:12 PM
> > It seems like the precompiler is unable to recognize the type MYSTRUCT
that I defined. yes, so if you wrap your typedefinition in a declare section, it should help ;)

Among my efforts to make it work I already tried to wrap the typedef into
the declare section and it worked, but I cannot do that, since I'm not
working on my code. I have to maintain already existing code and I cannot
change it so radically. I'm currently working under Windows, but the real
code should work under UNIX. I tried to compile it with PRO*C under UNIX
and it worked fine.

x
09-23-2004, 11:24 PM
> There is nothing to solve. The error message tells you, in a longwinded way, that structs are not supported.

Sorry, the message doesn't really tells me that. The message tells me that
the precompiler is unable to fine the struct definition.
I tried to compile the *same* code under UNIX and it worked fine, so it is
not a matter of what the language supports or not.
Oracle installation under UNIX was version 8i, whereas I'm working with
version 9i, but I think the precompiler should work the same way.
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.

Could you please give me some official reference reporting that ?
This is just a lowly precompiler after all.

Ok, but the Oracle PRO*C precompiler version 8.1.7.2.0, under UNIX compiled
the code without problems.

Bent Stigsen
09-24-2004, 06:25 AM
Andrea Laforgia wrote:It seems like the precompiler is unable to recognize the type MYSTRUCT thatI defined.yes, so if you wrap your typedefinition in a declare section, it shouldhelp ;) Among my efforts to make it work I already tried to wrap the typedef into the declare section and it worked, but I cannot do that, since I'm not working on my code. I have to maintain already existing code and I cannot change it so radically. I'm currently working under Windows, but the real code should work under UNIX. I tried to compile it with PRO*C under UNIX and it worked fine.

What?, you are converting code from unix to windows. ABOMINATION!

just kidding :), actually been there myself.

If you want to avoid the declare section, you can set "parse=full" in
the options for the precompiler, either in the "pcscfg.cfg" file or in
the commandline. Consequently perhaps you also need to add
"sys_include", which should point to the system header files.

You can read about the options in the "Pro C-C++ Precompiler Programmers
Guide" available at OTN.


/Bent

x
09-24-2004, 06:34 AM
> If you want to avoid the declare section, you can set "parse=full" in the options for the precompiler, either in the "pcscfg.cfg" file or in the commandline. Consequently perhaps you also need to add "sys_include", which should point to the system header files.

I did, of course.
You can read about the options in the "Pro C-C++ Precompiler Programmers Guide" available at OTN.

Thanks.

x
09-28-2004, 07:15 AM
Solution: using the Visual C++ include files (I was using C++ Builder ones),
it compiles successfully.
Thanks for the help ;-)

Ed prochak
09-29-2004, 09:04 AM
"Andrea Laforgia" <x@x.x> wrote in message news:<cjbv75$4b7$1@newsread.albacom.net>... Solution: using the Visual C++ include files (I was using C++ Builder ones), it compiles successfully. Thanks for the help ;-)

Thanks for the feedback. Sorry I cannot claim to have been any help in
this case, but it is nice to know if folks really do solve their
problems rather than just letting threads starve to death.

Interesting cause of the problem. Glad you solved it.

Have a great day.
Ed


MyLounge.com Site Map
Forum: Cars, Cell Phone, Database, Games, Home Improvement, IT, Music, School, Sports, Web Design, Web Server, Weight Loss

The MyLounge.com forum is intended for informational use only and should not be relied upon and is not a substitute for any advice. The information contained on MyLounge.com are opinions and suggestions of members and is not a representation of the opinions of MyLounge.com. MyLounge.com does not warrant or vouch for the accuracy, completeness or usefulness of any postings or the qualifications of any person responding. Please consult a expert or seek the services of an attorney in your area for more accuracy on your specific situation. Please note that our forums also serve as mirrors to Usenet newsgroups. Many posts you see on our forums are made by newsgroup users who may not be members of MyLounge.com Term of Service