0 Replies Latest reply: Sep 24, 2009 10:12 AM by 723802 RSS

    using object types in pro*c/c++

    723802
      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.