Home » Developer & Programmer » Precompilers, OCI & OCCI » Compilation errors
Compilation errors [message #94146] Wed, 31 March 2004 00:36
Lance
Messages: 2
Registered: April 1998
Junior Member
Hi,

I need some advie on compilig a C file, some history to aid in this process, I have a daemon.pc file that I run through the Pro*C precompiler using the following command

Proc iname=daemon userid=abre/abre sqlcheck=semantics

The daemon.pc file renders to the daemon.c file without any probelms, however, when I try and compile the daemon.c file I am returned with enough errors to choke on;

"daemon.c", line 109: warning: no explicit type given
"daemon.c", line 111: warning: no explicit type given
"daemon.c", line 113: warning: no explicit type given
"daemon.c", line 114: warning: no explicit type given
"daemon.c", line 115: warning: no explicit type given
"daemon.c", line 273: warning: implicit function declaration: sqlglm
"daemon.c", line 277: warning: implicit function declaration: exit
"daemon.c", line 292: warning: old-style declaration or incorrect type for: main
"daemon.c", line 462: warning: implicit function declaration: system

---------------

Below is the original daemon.pc code;

 

----------------

#include <stdio.h>
#include <string.h>
EXEC SQL include sqlca; 
EXEC SQL begin declare section;  
char *uid = "abre/abre"; 

int status;                

varchar command[[20]];       

varchar value[[2000]];       

varchar return_name[[30]];   

EXEC SQL end declare section;
 

void connect_error()
{  
 char msg_buffer[[512]];  
int msg_length;  
int buffer_size = 512;   
EXEC SQL whenever sqlerror continue;  
sqlglm(msg_buffer, &buffer_size, &msg_length);  
printf("Daemon error while connecting:n"); 
 printf("%.*sn", msg_length, msg_buffer);
  printf("Daemon quitting.n");
  exit(1); 
 } 

void sql_error()

  char msg_buffer[[512]];
  int msg_length; 
 int buffer_size = 512; 
  EXEC SQL whenever sqlerror continue; 
 sqlglm(msg_buffer, &buffer_size, &msg_length);
  printf("Daemon error while executing:n");
  printf("%.*sn", msg_length, msg_buffer);
  printf("Daemon continuing.n");   }  main()
 {  
 EXEC SQL whenever sqlerror do connect_error();
  EXEC SQL connect :uid;
  printf("Daemon connected.n"); 
  EXEC SQL whenever sqlerror do sql_error();
  printf("Daemon waiting...n");   while (1)
 {  

 

  EXEC SQL EXECUTE   
   begin      
  :status := dbms_pipe.receive_message('daemon');   
     if :status = 0 then      
    dbms_pipe.unpack_message(:command);    
    end if;  
    end;  
  END-EXEC; 
    if (status == 0)
 {  

    command.arr[[command.len]] = '';   
   if (!strcmp((char *)command.arr, "STOP"))
 {   

 

     printf("Daemon exiting.n");   
     break;  
      }   
    else if (!strcmp((char *)command.arr, "SYSTEM"))
 {     

 EXEC SQL EXECUTE   
       begin    
        dbms_pipe.unpack_message(:return_name);    
        dbms_pipe.unpack_message(:value);    
      end;  
      END-EXEC;    
    value.arr[[value.len]] = '';   
     printf("Will execute system command '%s'n", value.arr);   
  

      status = system(value.arr);    

 

     EXEC SQL EXECUTE    
      begin   
         dbms_pipe.pack_message('done');    
        dbms_pipe.pack_message(:status);    
        :status := dbms_pipe.send_message(:return_name);   
       end;    
    END-EXEC;  
       if (status)
{           printf("Daemon error while responding to system command.");  
        printf("  status: %dn", status); 
         }    
    }    
   else if (!strcmp((char *)command.arr, "SQL"))
 {     
     EXEC SQL EXECUTE   
       begin    
        dbms_pipe.unpack_message(:return_name);    
        dbms_pipe.unpack_message(:value);   
       end;     
   END-EXEC;   
     value.arr[[value.len]] = '';    
    printf("Will execute sql command '%s'n", value.arr);  
  

EXEC SQL whenever sqlerror continue;    
    EXEC SQL EXECUTE IMMEDIATE :value;     
   status = sqlca.sqlcode;      

 

     EXEC SQL whenever sqlerror do sql_error();    
    EXEC SQL EXECUTE     
     begin       
     dbms_pipe.pack_message('done');      
      dbms_pipe.pack_message(:status);   
         :status := dbms_pipe.send_message(:return_name);  
        end;     
   END-EXEC;    
     if (status)
{     

     printf("Daemon error while responding to sql command.");    
      printf("  status: %dn", status);     
     }     
   }     
  else
 {       

    printf("Daemon error: invalid command '%s' received.n", command.arr);  
      }  
    }  
  else {  

    printf("Daemon error while waiting for signal.");  
    printf("  status = %dn", status);  
    } 
 } 
  EXEC SQL commit work release; }

--------------------

 

Any help and advice would be most appreciated.

Lance
Previous Topic: Basics of Pro*C
Next Topic: Extracting table/view name(s) from dynamic sql.
Goto Forum:
  


Current Time: Thu Apr 18 16:21:25 CDT 2024