Home » Developer & Programmer » Precompilers, OCI & OCCI » using object types in pro*c/c++ (Oracle 11g, sun solaris)
using object types in pro*c/c++ [message #423473] Thu, 24 September 2009 10:04 Go to next message
hysat429
Messages: 4
Registered: September 2009
Location: US
Junior Member
HI all,

I am trying to use oracle object types in pro*c/c++ program. Below are the detailes.

objects being used OBJ_BACKGROUND_JOB , OBJ_BACKGROUND_JOB_ARRAY.

ott infile : inpfile
CASE=SAME
TYPE OBJ_BACKGROUND_JOB
TYPE OBJ_BACKGROUND_JOB_ARRAY

ott command : ott userid=scott/tiger code=C intype=inpfile outtype=ottouttype hfile=obj_background_job_array.h

the command generated the header file and an outtype file
obj_background_job_array.h :
#ifndef OBJ_BACKGROUND_JOB_ARRAY_ORACLE
# define OBJ_BACKGROUND_JOB_ARRAY_ORACLE

#ifndef OCI_ORACLE
# include <oci.h>
#endif

typedef OCIRef OBJ_BACKGROUND_JOB_ref;
typedef OCITable OBJ_BACKGROUND_JOB_ARRAY;

struct OBJ_BACKGROUND_JOB
{
OCINumber SNO;
OCIString * PARAMETER;
};
typedef struct OBJ_BACKGROUND_JOB OBJ_BACKGROUND_JOB;

struct OBJ_BACKGROUND_JOB_ind
{
OCIInd _atomic;
OCIInd SNO;
OCIInd PARAMETER;
};
typedef struct OBJ_BACKGROUND_JOB_ind OBJ_BACKGROUND_JOB_ind;

ott outtype file : ottouttype.typ
CASE = SAME

TYPE OBJ_BACKGROUND_JOB AS OBJ_BACKGROUND_JOB
VERSION = "$8.0"
HFILE = obj_background_job_array.h

TYPE OBJ_BACKGROUND_JOB_ARRAY AS OBJ_BACKGROUND_JOB_ARRAY
VERSION = "$8.0"
HFILE = obj_background_job_array.h

below is the proc code in which I am using the above defined types : types.pc
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sqllib.h>
#include <sql2oci.h>
#include <sqlda.h>
#include "obj_background_job_array.h"
#define SQLCA_STORAGE_CLASS extern
int main()
{

EXEC SQL BEGIN DECLARE SECTION ;
OCIString * abcd ;
OBJ_BACKGROUND_JOB * obj_background_job ;
OBJ_BACKGROUND_JOB_ind * obj_background_job_ind ;
OCIString * abc ;
EXEC SQL END DECLARE SECTION ;

EXEC SQL ALLOCATE :abc;
EXEC SQL ALLOCATE :abcd;
EXEC SQL ALLOCATE :obj_background_job:obj_background_job_ind ;
.
.
.
return 0 ;

}

When i compile the above code using the command :
proc types config=pcscfg.cfg
i get the below error
Syntax error at line 24, column 9, file types.pc:
Error at line 24, column 9 in file types.pc
OBJ_BACKGROUND_JOB * obj_background_job ;
........1
PCC-S-02201, Encountered the symbol "OBJ_BACKGROUND_JOB" when expecting one of t
he 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 "OBJ_BACKGROUND_JOB" to continue.

Syntax error at line 25, column 9, file types.pc:
Error at line 25, column 9 in file types.pc
OBJ_BACKGROUND_JOB_ind * obj_background_job_ind ;
........1
PCC-S-02201, Encountered the symbol "OBJ_BACKGROUND_JOB_ind" 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 "OBJ_BACKGROUND_JOB_ind" to continue.
Error at line 0, column 0 in file types.pc
PCC-F-02102, Fatal error while doing C preprocessing



contents of pcscfg.cfg is :
USERID=scott/tiger
code=cpp
parse=none
define=DM_PAGE_SIZE
release_cursor=yes
sqlcheck=semantics
INTYPE=ottouttype.typ
OBJECTS=YES
sys_include=(/apps/util/oracle/product/11.1.0-64bit/precomp/public,/opt/SUNWspro6u1/WS6U1/include/CC4,/usr/include)
ltype=short
MODE=ORACLE

It seems INTYPE=ottouttype.typ parameter doesnt have any effect on the proc command.
Please suggest on how to resolve the problem ... Thanks in advance for your help.
Re: using object types in pro*c/c++ [message #423659 is a reply to message #423473] Sat, 26 September 2009 01:31 Go to previous messageGo to next message
Kevin Meade
Messages: 2103
Registered: December 1999
Location: Connecticut USA
Senior Member
you have some syntax error. I am no expert in C but I can offer these observations from plsql when I get the same error. In order of most common mistakes:

1) missing a quote
2) missing a matching end for some start.  
   Example IF with no matching end if; loop with no matching end loop;  
   The problem is usually that the end tag exists but is out of place.
3) missing an ending token (eg. ; in plsql)
4) missing some other token (exp. said = instead of :=)
5) mis-spelled some variable and the parser is confused so it reports an erroneous error.

I suggest you look for a syntax error of the types above, the C version of course.

My approach to solving the problem is to comment out everything, and then compile iteratively bringing in small pieces as I go. Eventually I find the line/section with the error and then it is easier to see and fix.

Good luck, Kevin

[Updated on: Sat, 26 September 2009 10:02] by Moderator

Report message to a moderator

Re: using object types in pro*c/c++ [message #423670 is a reply to message #423659] Sat, 26 September 2009 05:20 Go to previous message
hysat429
Messages: 4
Registered: September 2009
Location: US
Junior Member
Hey Kevin,

I also did the same procedure of commenting/uncommenting the code , the code gets compiled if i comment the code instantiating the ott structures as host variables. I can use them as a normal C structures and operate on them, then here i cannot use the sql command like allocate, object get , object set on those C variables.
Previous Topic: Proper use of ConnectionPool in OCCI
Next Topic: ORA-01044: size 25600000 Error in oexec call
Goto Forum:
  


Current Time: Thu Mar 28 13:44:52 CDT 2024