5 Replies Latest reply on Jul 4, 2011 7:12 AM by 812131

    Pro*c errors in 11g. -- Compiles fine in 10g.

    733710
      Hi,

      We are planning to migrate from 10g to 11g so started compiling our Pro*c code in to 11g. Got several errors and couldn't trace. So to investigate further I have written a basic pro*c program as follows:
      #include <stdio.h>
      
      #include <sqlca.h>
      /*#include <sqlcpr.h>*/
      #include <oraca.h>
      #include <sqlda.h>
      
      /* Declare error handling function. */
      void sql_error();
      
      int main(int argc, char** argv)
      {
      char user[]="myusername";
      char pwd[]="mypassword";
      char msg_buf[51]="";
      
      /* Register sql_error() as the error handler. */
      EXEC SQL WHENEVER SQLERROR DO sql_error("ORACLE error\n");
      
      EXEC SQL CONNECT :user IDENTIFIED BY :pwd;
      
      EXEC SQL
      INSERT INTO hello_world
      VALUES ('Hello world!');
      
      EXEC SQL COMMIT;
      
      EXEC SQL
      SELECT msg
      INTO :msg_buf
      FROM hello_world
      WHERE rownum <= 1; 
      
      printf("%s\n", msg_buf);
      
      return(0); 
      }
      
      void sql_error(char *msg) 
      {
      char err_msg[128]; 
      int buf_len, msg_len; 
      
      EXEC SQL WHENEVER SQLERROR CONTINUE; 
      
      printf("%s\n", msg); 
      buf_len = sizeof (err_msg); 
      sqlglm(err_msg, &buf_len, &msg_len); 
      
      if (msg_len > buf_len)
      msg_len = buf_len;
      
      printf("%.*s\n", msg_len, err_msg);
      
      EXEC SQL ROLLBACK RELEASE;
      
      exit(1);
      }
      And then did the following:
      proc iname=hellodb.pc MODE=ORACLE 
      it has created a .c file.

      Now run
      /opt/ansic/bin/cc -g  -I. -I${ORACLE_HOME}/precomp/public -c hellodb.c -o hellodb
      which gave me a big list of errors / warnings.
      "hellodb.c", line 117: warning #2837-D: omission of explicit type is
                nonstandard ("int" assumed)
        extern sqlcxt ( void **, unsigned int *,
               ^
      
      "hellodb.c", line 119: warning #2837-D: omission of explicit type is
                nonstandard ("int" assumed)
        extern sqlcx2t( void **, unsigned int *,
               ^
      
      "hellodb.c", line 121: warning #2837-D: omission of explicit type is
                nonstandard ("int" assumed)
        extern sqlbuft( void **, char * );
               ^
      
      "hellodb.c", line 122: warning #2837-D: omission of explicit type is
                nonstandard ("int" assumed)
        extern sqlgs2t( void **, char * );
               ^
      
      "hellodb.c", line 123: warning #2837-D: omission of explicit type is
                nonstandard ("int" assumed)
        extern sqlorat( void **, unsigned int *, void * );
               ^
      
      "hellodb.c", line 316: warning #2223-D: function "sqlglm" declared implicitly
        sqlglm(err_msg, &buf_len, &msg_len); 
        ^
      
      "hellodb.c", line 342: warning #2223-D: function "exit" declared implicitly
        exit(1);
      I did the same in another server which is having 10g installation and it went on well and created the exe hellodb.

      Any idea what these errors are?

      Thanks in advance,
      Deep.

      Edited by: user11984804 on 06-Apr-2010 03:49
        • 1. Re: Pro*c errors in 11g. -- Compiles fine in 10g.
          733710
          Can any one help me?

          More Info: It is on HP:UX machine.

          Followed Oracle Note: 467931.1 (https://support.oracle.com/CSP/main/article?cmd=show&id=467931.1&type=NOT) to install.

          Thanks in advance.
          • 2. Re: Pro*c errors in 11g. -- Compiles fine in 10g.
            794035
            Hi, I found this solution, only add an argument in the precompiler CODE=ANSI_C. As an example below.


            opt/oracle/product/10.2.0/Db_1/bin/proc CODE=ANSI_C MODE=ansi include=../comun/include nclude=. ../comun/lib/sample.pc

            It generate, function protitypes in ANSI C mode.

            When you compile with cc o gcc it's fine.

            cc -Ae -c -g -I ../comun/include -I. ../comun/lib/sample.c

            Edited by: user10095949 on 26/08/2010 09:13 AM

            Edited by: user10095949 on 26/08/2010 09:16 AM
            • 3. Re: Pro*c errors in 11g. -- Compiles fine in 10g.
              812131
              Hello,

              We face the similar problem.Our database migrated from oracle 11.2.0.2 from 10g.
              PRO*C compilation is not happening with so may warnings and 1 error below
              error #4313-D: no prototype or definition in scope for call to memory allocation routine "malloc".

              Could you please provide the solution.
              • 4. Re: Pro*c errors in 11g. -- Compiles fine in 10g.
                812131
                Hello,

                We face the similar problem.Our database is migrated to 11.2.0.2 from 10g.
                PRO*C compilation is not happening with so many warnings and 1 error below
                error #4313-D: no prototype or definition in scope for call to memory allocation routine "malloc".

                Could you please provide the solution.

                we are using the following command to compile PRO*C
                make -f $ORACLE_HOME/precomp/demo/proc/demo_proc.mk EXE=$program OBJS=$program.o PROCFLAGS="sqlcheck=full userid=<username>/<password>@oraclesid" build

                Edited by: user12058331 on 30-Jun-2011 04:02

                Edited by: user12058331 on 30-Jun-2011 04:05
                • 5. Re: Pro*c errors in 11g. -- Compiles fine in 10g.
                  812131
                  I got problem solved by explicitely defining the malloc prototype definition in the PRO*Cwhich is not required in previous releases of ORACLE