Home » Developer & Programmer » Precompilers, OCI & OCCI » How can I compile simple PRO*C code in Linux (Oracle 10g, Linux)
How can I compile simple PRO*C code in Linux [message #357629] Thu, 06 November 2008 01:41 Go to next message
appc
Messages: 3
Registered: November 2008
Junior Member
Linux 2.4.21-37.ELsmp #1 SMP Wed Sep 7 13:28:55 EDT 2005 i686 i686 i386 GNU/Linux

As you'll see I do not understand anything about PRO*C. I need to compile this PRO*C code to use it to retrieve DBMS PIPES being sent.

I'm trying to compile it using the following command:
gcc -o IAPIPE IAPIPE.c



The code - file IAPIPE.c

#include <stdio.h>
#include <string.h>

EXEC SQL BEGIN DECLARE SECTION;
VARCHAR username[20];
int status;
int msg_length;
char retval[2000];
EXEC SQL END DECLARE SECTION;

EXEC SQL INCLUDE SQLCA;

void sql_error();

main()
{

-- Prepare username:
strcpy(username.arr, "SCOTT/TIGER");
username.len = strlen(username.arr);

EXEC SQL WHENEVER SQLERROR DO sql_error();
EXEC SQL CONNECT :username;

printf("connected\n");

-- Start an endless loop to look for and print messages on the pipe:
FOR (;;)
{
EXEC SQL EXECUTE
DECLARE
len INTEGER;
typ INTEGER;
sta INTEGER;
chr VARCHAR2(2000);
BEGIN
chr := '';
sta := dbms_pipe.receive_message('plsql_debug');
IF sta = 0 THEN
DBMS_PIPE.UNPACK_MESSAGE(len);
DBMS_PIPE.UNPACK_MESSAGE(chr);
END IF;
:status := sta;
:retval := chr;
IF len IS NOT NULL THEN
:msg_length := len;
ELSE
:msg_length := 2000;
END IF;
END;
END-EXEC;
IF (status == 0)
printf("\n%.*s\n", msg_length, retval);
ELSE
printf("abnormal status, value is %d\n", status);
}
}

void sql_error()
{
char msg[1024];
int rlen, len;
len = sizeof(msg);
sqlglm(msg, &len, &rlen);
printf("ORACLE ERROR\n");
printf("%.*s\n", rlen, msg);
exit(1);
}


The Errors

IAPIPE.c:4: parse error before `SQL'
IAPIPE.c:4: warning: data definition has no type or storage class
IAPIPE.c:5: parse error before `username'
IAPIPE.c:5: warning: data definition has no type or storage class
IAPIPE.c:9: parse error before `SQL'
IAPIPE.c:9: warning: data definition has no type or storage class
IAPIPE.c:11: parse error before `SQL'
IAPIPE.c:11: warning: data definition has no type or storage class
IAPIPE.c: In function `main':
IAPIPE.c:18: `Prepare' undeclared (first use in this function)
IAPIPE.c:18: (Each undeclared identifier is reported only once
IAPIPE.c:18: for each function it appears in.)
IAPIPE.c:18: parse error before `username'
IAPIPE.c:20: request for member `len' in something not a structure or union
IAPIPE.c:20: request for member `arr' in something not a structure or union
IAPIPE.c:22: `EXEC' undeclared (first use in this function)
IAPIPE.c:22: parse error before `SQL'
IAPIPE.c:27: `Start' undeclared (first use in this function)
IAPIPE.c:27: parse error before `an'
IAPIPE.c:33: `typ' undeclared (first use in this function)
IAPIPE.c:34: `sta' undeclared (first use in this function)
IAPIPE.c:35: `chr' undeclared (first use in this function)
IAPIPE.c:37: `BEGIN' undeclared (first use in this function)
IAPIPE.c:37: empty character constant
IAPIPE.c:38: `dbms_pipe' undeclared (first use in this function)
IAPIPE.c:38: character constant too long
IAPIPE.c:39: `IF' undeclared (first use in this function)
IAPIPE.c:39: parse error before `sta'
IAPIPE.c:41: `DBMS_PIPE' undeclared (first use in this function)
IAPIPE.c:42: `END' undeclared (first use in this function)
IAPIPE.c:42: parse error before `IF'
IAPIPE.c:48: invalid operands to binary unknown
IAPIPE.c:49: parse error before `IF'
IAPIPE.c:52: `IF' used prior to declaration
IAPIPE.c:53: parse error before `printf'
IAPIPE.c:55: `ELSE' undeclared (first use in this function)



Thanks in advance for your time and your help!
Re: How can I compile simple PRO*C code in Linux [message #357630 is a reply to message #357629] Thu, 06 November 2008 01:43 Go to previous messageGo to next message
appc
Messages: 3
Registered: November 2008
Junior Member
I'm running Oracle EBusiness 11.5.10 in this box, with Oracle 10g.

Thanks again.
Re: How can I compile simple PRO*C code in Linux [message #357735 is a reply to message #357629] Thu, 06 November 2008 07:06 Go to previous messageGo to next message
vicenzo
Messages: 28
Registered: December 2007
Location: Paris
Junior Member
you needd to precompile your code with the Oracle pre-compiler (proc) and then compile the resulting out source file with gcc
Re: How can I compile simple PRO*C code in Linux [message #357789 is a reply to message #357735] Thu, 06 November 2008 10:01 Go to previous message
appc
Messages: 3
Registered: November 2008
Junior Member
Thanks.

So I renamed my file from IAPIPE.c to IAPIPE.pc.

Now when I

proc IAPIPE.pc

Pro*C/C++: Release 8.0.6.3.0 - Production on Thu Nov 6 09:41:51 2008

(c) Copyright 1999 Oracle Corporation. All rights reserved.

System default option values taken from: /s01/oracle/dev/devora/8.0.6/precomp/admin/pcscfg.cfg

Error at line 34, column 11 in file /usr/include/stdio.h
# include <stddef.h>
..........1
PCC-S-02015, unable to open include file
Error at line 31, column 10 in file /usr/include/bits/types.h
#include <stddef.h>
.........1
PCC-S-02015, unable to open include file
Error at line 14, column 10 in file /usr/include/_G_config.h
#include <stddef.h>
.........1
PCC-S-02015, unable to open include file
Error at line 48, column 10 in file /usr/include/wchar.h
#include <stddef.h>
.........1
PCC-S-02015, unable to open include file
Error at line 48, column 10 in file /usr/include/wchar.h
#include <stddef.h>
.........1
PCC-S-02015, unable to open include file
Error at line 31, column 10 in file /usr/include/gconv.h
#include <stddef.h>
.........1
PCC-S-02015, unable to open include file
Syntax error at line 72, column 26, file /usr/include/gconv.h:
Error at line 72, column 26 in file /usr/include/gconv.h
unsigned char **, size_t *, int, int);
.........................1
PCC-S-02201, Encountered the symbol "size_t" when expecting one of the following:

... auto, char, const, double, enum, float, int, long,
OCIBFileLocator OCIBlobLocator, OCIClobLocator, OCIDate,
OCINumber, OCIRaw, OCIString, register, short, signed,
sql_context, sql_cursor, static, struct, union, unsigned,
varchar, void, volatile, a typedef name, exec oracle,
exec oracle begin, exec, exec sql, exec sql begin,
exec sql type, exec sql var,
The symbol "enum," was substituted for "size_t" to continue.

Syntax error at line 88, column 7, file /usr/include/gconv.h:
Error at line 88, column 7 in file /usr/include/gconv.h
size_t *);
......1
PCC-S-02201, Encountered the symbol "size_t" when expecting one of the following
:

... auto, char, const, double, enum, float, int, long,
OCIBFileLocator OCIBlobLocator, OCIClobLocator, OCIDate,
OCINumber, OCIRaw, OCIString, register, short, signed,
sql_context, sql_cursor, static, struct, union, unsigned,
varchar, void, volatile, a typedef name, exec oracle,
exec oracle begin, exec, exec sql, exec sql begin,
exec sql type, exec sql var,
The symbol "enum," was substituted for "size_t" to continue.

Syntax error at line 97, column 6, file /usr/include/gconv.h:
Error at line 97, column 6 in file /usr/include/gconv.h
size_t *);
.....1
PCC-S-02201, Encountered the symbol "size_t" when expecting one of the following
:

... auto, char, const, double, enum, float, int, long,
OCIBFileLocator OCIBlobLocator, OCIClobLocator, OCIDate,
OCINumber, OCIRaw, OCIString, register, short, signed,
sql_context, sql_cursor, static, struct, union, unsigned,
varchar, void, volatile, a typedef name, exec oracle,
exec oracle begin, exec, exec sql, exec sql begin,
exec sql type, exec sql var,
The symbol "enum," was substituted for "size_t" to continue.

Syntax error at line 106, column 3, file /usr/include/gconv.h:
Error at line 106, column 3 in file /usr/include/gconv.h
__gconv_trans_fct __trans_fct;
..1
PCC-S-02201, Encountered the symbol "__gconv_trans_fct" when expecting one of th
e following:

char, const, double, enum, float, int, long, OCIBFileLocator
OCIBlobLocator, OCIClobLocator, OCIDate, OCINumber, OCIRaw,
OCIString, short, signed, sql_context, sql_cursor, struct,
union, unsigned, varchar, void, volatile, a typedef name,

Error at line 53, column 11 in file /usr/include/libio.h
# include <stdarg.h>
..........1
PCC-S-02015, unable to open include file
Error at line 33, column 10 in file /usr/include/string.h
#include <stddef.h>
.........1
PCC-S-02015, unable to open include file
Error at line 0, column 0 in file IAPIPE.pc
PCC-F-02102, Fatal error while doing C preprocessing





What am I missing?
Previous Topic: sqlcxt crash - signal SEGV (no mapping at the fault address)
Next Topic: Example for OCI or OCCI needed
Goto Forum:
  


Current Time: Fri Mar 29 07:42:50 CDT 2024