Oracle预编译器DLL库

时间:2010-01-04 18:50:22

标签: oracle dll oracle-pro-c

平台:运行Oracle 10g的Windows

我必须修改一些旧的dll库代码并使用Oracle进行预编译 Pro * C / C ++ 9.0.1.1.1,现在我发现了代码 for(;;)无论什么时候没有找到,休息不再有效,它只是保持 循环。 我在这里准备了一些代码,显示在预编译之前和之后 还有一个日志。 在此先感谢能够提供帮助的人。

(A) the PC program 

/************************************************************************/ 
/* fmt_clnt.pc                                                          */ 
/************************************************************************/ 
#include <stdlib.h> 
#include <string.h> 
#include <process.h> 
#include <stdio.h> 
#include <windows.h> 
/*--------------------------------------------------------------------------+ 
 | Copyright (c) Oracle Corporation 1993.  All Rights Reserved, Worldwide.  | 
 |                                                                          | 
 | NAME                                                                     | 
 |   ue.h - User Exit Functions Header File.                                | 
 |                                                                          | 
 | FUNCTION                                                                 | 
 |    Define the exitr structure. Misc defines.                             | 
 |                                                                          | 
 | CONTENTS                                                                 | 
 |                                                                          | 
 | NOTES                                                                    | 
 |                                                                          | 
 | MODIFIED                                                                 | 
 |  KMajkut  03/23/93 Created. Split off from old ue.h                      | 
 |                    Added definition of exitr from usrxit.h               | 
 +-------------------------------------------------------------------------*/ 

#ifndef UE 
#define UE 

#define MAX_ERRBUF_SIZE    256 

extern char  SRWERB[]; 

struct  exitr                           /* Struct definition for exits */ 
{ 
         char     *exnam;               /* Name of the user exit */ 
         int       (*exfp)(/*_ char* _*/);   /* Pointer to exit routine */ 
         int       extyp;               /* Type code for exit routine  */ 
#define  XITCC1    1                    /* C (for existing exits)      */ 
#define  XITCC     2                    /* C (call-by-reference)       */ 
#define  XITCOB    3                    /* Cobol                      */ 
#define  XITFOR    4                    /* Fortran                    */ 
#define  XITPLI    5                    /* PL/I                             */ 
#define  XITPAS    6                    /* Pascal                           */ 
#define  XITAda    7                    /* Ada                              */ 
}; 

/* Failure and Success return codes */ 
#define    FATAL_ERR  535    /* Use this on really bad errors */ 
#define    FAILURE  1403   /* Use this on recoverable error */ 
#define    SUCCESS  0      /* Use for success */ 

typedef struct exitr exitr; 

extern exitr iapxtb[]; 


#endif /* UE */ 

#define NORMAL      0 
#define HYFAILED      1 


# define externdef globaldef 


extern int fmt_clnt(); 
extern int inv_msp(); 
extern int inv_ism(); 
extern int readmsp(); 
extern int coll_bad(); 
/*******************************************************************/ 
exec sql begin declare section; 
char   frm_batch_str[10]; 
int    status; 
long   batch; 
long   todays_batch; 
int    loopcnt; 
char   sub_code[2]; 
char   description[61]; 

exec sql end declare section; 
/*******************************************************************/ 
/* exec sql INCLUDE sqlca; */ 

#ifndef    SQLCODE 
struct     sqlca 
{ 
           unsigned char  sqlcaid[8]; 
           long           sqlcabc; 
           long           sqlcode; 
           short          sqlerrml; 
           unsigned char  sqlerrmc[70]; 
           unsigned char  sqlerrp[8]; 
           long           sqlerrd[6]; 
           unsigned char  sqlwarn[11]; 
           unsigned char  sqlstate[5]; 
}; 
#define      SQLCODE   sqlca.sqlcode 
#define      SQLWARN0  sqlca.sqlwarn[0] 
#define      SQLWARN1  sqlca.sqlwarn[1] 
#define      SQLWARN2  sqlca.sqlwarn[2] 
#define      SQLWARN3  sqlca.sqlwarn[3] 
#define      SQLWARN4  sqlca.sqlwarn[4] 
#define      SQLWARN5  sqlca.sqlwarn[5] 
#define      SQLWARN6  sqlca.sqlwarn[6] 
#define      SQLWARN7  sqlca.sqlwarn[7] 
#define      SQLWARN8  sqlca.sqlwarn[8] 
#define      SQLWARN9  sqlca.sqlwarn[9] 
#define      SQLWARNA  sqlca.sqlwarn[10] 
#define      SQLSTATE  sqlca.sqlstate 
#endif 
struct sqlca sqlca; 

/********************************************/ 

FILE   *logfp; 
int    sql_err(); 
int    call_sqlca_flags (); 
/*******************************************************************/ 
/*******************************************************************/ 
/*                         Main program                            */ 
/*******************************************************************/ 
/*******************************************************************/ 
int fmt_clnt() 
{         
   int i = 1; 
   int status = 0; 
   logfp = fopen("format.txt", "w"); 
   fprintf(logfp, "fmt_clnt version is HY2009Q4\n"); 
   strcpy(frm_batch_str, " "); 
   /****************************************************/ 
   /* get batch number from Forms program              */ 
   /****************************************************/ 
   /* exec iaf get reqdata.batch into :frm_batch_str;  */ 
   exec tools get reqdata.batch into :frm_batch_str;  
   /*****************************************************/ 
   /* Make sure dbms is accessible                      */ 
   /*****************************************************/ 
   exec sql whenever sqlerror do sql_err("Debug 1\n");  
   exec sql select max(batch) into :todays_batch from bill_test; 
   fprintf(logfp, "High batch is %d\n", todays_batch); 
/*******************************************************************/ 
/*******************************************************************/ 
/*                         For Loop Debug                          */ 
/*******************************************************************/ 
/*******************************************************************/ 
   fprintf(logfp, "Only 8 entries in table but will loop forever\n"); 
   fprintf(logfp, "For (;;) loop change to max 20 to force breaking out\n"); 
   exec sql declare c1 cursor for 
       select sub_code, description from submission_code where 1=1 order by sub_code; 
   exec sql OPEN c1; 
   exec sql whenever not found do break; 
   for (i; i < 20 ; ++ i) 
      { 
      exec sql fetch c1 into :sub_code, :description; 
      fprintf(logfp, "When i=%d sqlcode=%d sub_code=%s desc=%s\n", i,sqlca.sqlcode,sub_code,description);  
      } 
   exec sql CLOSE c1; 
/*******************************************************************/ 
/*******************************************************************/ 
/*******************************************************************/ 
/*                       End For Loop Debug                        */ 
/*******************************************************************/ 
/*******************************************************************/ 
   if (status == HYFAILED || status == IAPFAIL)  
      return (IAPFAIL); 
   fclose(logfp); 
   return (IAPSUCC); 
} 
/*******************************************************************/ 
/*******************************************************************/ 
/*                       SQL_ERR trapping                          */ 
/*******************************************************************/ 
/*******************************************************************/ 
int sql_err(msg) 
char *msg; 
{ 
char err_msg[128]; 
int  msg_len;     
/*hy   strcpy (err_msg, sqlca.sqlerrm.sqlerrmc);  */ 
   msg_len = strlen (err_msg); 
   fprintf(logfp, "error %s\n", err_msg); 
   exec sql ROLLBACK; 
   return (IAPFAIL); 
} 
/*******************************************************************/ 
/*******************************************************************/ 



(B) the C program after the precompile 

/* Result Sets Interface */ 
#ifndef SQL_CRSR 
#  define SQL_CRSR 
  struct sql_cursor 
  { 
    unsigned int curocn; 
    void *ptr1; 
    void *ptr2; 
    unsigned long magic; 
  }; 
  typedef struct sql_cursor sql_cursor; 
  typedef struct sql_cursor SQL_CURSOR; 
#endif /* SQL_CRSR */ 

/* Thread Safety */ 
typedef void * sql_context; 
typedef void * SQL_CONTEXT; 

/* Object support */ 
struct sqltvn 
{ 
  unsigned char *tvnvsn; 
  unsigned short tvnvsnl; 
  unsigned char *tvnnm; 
  unsigned short tvnnml; 
  unsigned char *tvnsnm; 
  unsigned short tvnsnml; 
}; 
typedef struct sqltvn sqltvn; 

struct sqladts 
{ 
  unsigned int adtvsn; 
  unsigned short adtmode; 
  unsigned short adtnum;  
  sqltvn adttvn[1];       
}; 
typedef struct sqladts sqladts; 

static struct sqladts sqladt = { 
  1,1,0, 
}; 

/* Binding to PL/SQL Records */ 
struct sqltdss 
{ 
  unsigned int tdsvsn; 
  unsigned short tdsnum; 
  unsigned char *tdsval[1]; 
}; 
typedef struct sqltdss sqltdss; 
static struct sqltdss sqltds = 
{ 
  1, 
  0, 
}; 


static char sqh000[] = "REQDATA.BATCH"; 
/* File name & Package Name */ 
struct sqlcxp 
{ 
  unsigned short fillen; 
           char  filnam[22]; 
}; 
static const struct sqlcxp sqlfpn = 
{ 
    21, 
    "C:\\puzzle\\FMT_CLNT.PC" 
}; 


static unsigned long sqlctx = 146507995; 


static struct sqlexd { 
   unsigned int   sqlvsn; 
   unsigned int   arrsiz; 
   unsigned int   iters; 
   unsigned int   offset; 
   unsigned short selerr; 
   unsigned short sqlety; 
   unsigned int   occurs; 
      const short *cud; 
   unsigned char  *sqlest; 
      const char  *stmt; 
   sqladts *sqladtp; 
   sqltdss *sqltdsp; 
            void  **sqphsv; 
   unsigned int   *sqphsl; 
            int   *sqphss; 
            void  **sqpind; 
            int   *sqpins; 
   unsigned int   *sqparm; 
   unsigned int   **sqparc; 
   unsigned short  *sqpadto; 
   unsigned short  *sqptdso; 
            void  *sqhstv[2]; 
   unsigned int   sqhstl[2]; 
            int   sqhsts[2]; 
            void  *sqindv[2]; 
            int   sqinds[2]; 
   unsigned int   sqharm[2]; 
   unsigned int   *sqharc[2]; 
   unsigned short  sqadto[2]; 
   unsigned short  sqtdso[2]; 
} sqlstm = {10,2}; 

/* SQLLIB Prototypes */ 
extern void sqlcxt (void **, unsigned long *, 
                    struct sqlexd *, const struct sqlcxp *); 
extern void sqlcx2t(void **, unsigned long *, 
                    struct sqlexd *, const struct sqlcxp *); 
extern void sqlbuft(void **, char *); 
extern void sqlgs2t(void **, char *); 
extern void sqlorat(void **, unsigned long *, void *); 

/* Forms Interface */ 
static const int IAPSUCC = 0; 
static const int IAPFAIL = 1403; 
static const int IAPFTL  = 535; 
extern void sqliem(char *, int *); 

 static const char *sq0003 = 
"select sub_code ,description  from submission_code where 1=1 order by sub_co\ 
de            "; 

typedef struct { unsigned short len; unsigned char arr[1]; } VARCHAR; 
typedef struct { unsigned short len; unsigned char arr[1]; } varchar; 

/* cud (compilation unit data) array */ 
static const short sqlcud0[] = 
{10,4130,178,0,0, 
5,0,0,1,0,0,51,152,0,0,2,1,0,1,0,1,1,0,0,2,97,0,0, 
28,0,0,2,43,0,4,157,0,0,1,0,0,1,0,2,3,0,0, 
47,0,0,3,90,0,9,168,0,0,0,0,0,1,0, 
62,0,0,3,0,0,13,172,0,0,2,0,0,1,0,2,97,0,0,2,97,0,0, 
85,0,0,3,0,0,15,175,0,0,0,0,0,1,0, 
100,0,0,4,0,0,31,200,0,0,0,0,0,1,0, 
}; 


/************************************************************************/ 
/* fmt_clnt.pc                                                          */ 
/************************************************************************/ 
#include <stdlib.h> 
#include <string.h> 
#include <process.h> 
#include <stdio.h> 
#include <windows.h> 
/*--------------------------------------------------------------------------+ 
 | Copyright (c) Oracle Corporation 1993.  All Rights Reserved, Worldwide.  | 
 |                                                                          | 
 | NAME                                                                     | 
 |   ue.h - User Exit Functions Header File.                                | 
 |                                                                          | 
 | FUNCTION                                                                 | 
 |    Define the exitr structure. Misc defines.                             | 
 |                                                                          | 
 | CONTENTS                                                                 | 
 |                                                                          | 
 | NOTES                                                                    | 
 |                                                                          | 
 | MODIFIED                                                                 | 
 |  KMajkut  03/23/93 Created. Split off from old ue.h                      | 
 |                    Added definition of exitr from usrxit.h               | 
 +-------------------------------------------------------------------------*/ 

#ifndef UE 
#define UE 

#define MAX_ERRBUF_SIZE    256 

extern char  SRWERB[]; 

struct  exitr                           /* Struct definition for exits */ 
{ 
         char     *exnam;               /* Name of the user exit */ 
         int       (*exfp)(/*_ char* _*/);   /* Pointer to exit routine */ 
         int       extyp;               /* Type code for exit routine  */ 
#define  XITCC1    1                    /* C (for existing exits)      */ 
#define  XITCC     2                    /* C (call-by-reference)       */ 
#define  XITCOB    3                    /* Cobol                      */ 
#define  XITFOR    4                    /* Fortran                    */ 
#define  XITPLI    5                    /* PL/I                             */ 
#define  XITPAS    6                    /* Pascal                           */ 
#define  XITAda    7                    /* Ada                              */ 
}; 

/* Failure and Success return codes */ 
#define    FATAL_ERR  535    /* Use this on really bad errors */ 
#define    FAILURE  1403   /* Use this on recoverable error */ 
#define    SUCCESS  0      /* Use for success */ 

typedef struct exitr exitr; 

extern exitr iapxtb[]; 


#endif /* UE */ 

#define NORMAL      0 
#define HYFAILED      1 


# define externdef globaldef 


extern int fmt_clnt(); 
extern int inv_msp(); 
extern int inv_ism(); 
extern int readmsp(); 
extern int coll_bad(); 
/*******************************************************************/ 
/* exec sql begin declare section; */ 

char   frm_batch_str[10]; 
int    status; 
long   batch; 
long   todays_batch; 
int    loopcnt; 
char   sub_code[2]; 
char   description[61]; 

/* exec sql end declare section; */ 

/*******************************************************************/ 
/* exec sql INCLUDE sqlca; */ 

#ifndef    SQLCODE 
struct     sqlca 
{ 
           unsigned char  sqlcaid[8]; 
           long           sqlcabc; 
           long           sqlcode; 
           short          sqlerrml; 
           unsigned char  sqlerrmc[70]; 
           unsigned char  sqlerrp[8]; 
           long           sqlerrd[6]; 
           unsigned char  sqlwarn[11]; 
           unsigned char  sqlstate[5]; 
}; 
#define      SQLCODE   sqlca.sqlcode 
#define      SQLWARN0  sqlca.sqlwarn[0] 
#define      SQLWARN1  sqlca.sqlwarn[1] 
#define      SQLWARN2  sqlca.sqlwarn[2] 
#define      SQLWARN3  sqlca.sqlwarn[3] 
#define      SQLWARN4  sqlca.sqlwarn[4] 
#define      SQLWARN5  sqlca.sqlwarn[5] 
#define      SQLWARN6  sqlca.sqlwarn[6] 
#define      SQLWARN7  sqlca.sqlwarn[7] 
#define      SQLWARN8  sqlca.sqlwarn[8] 
#define      SQLWARN9  sqlca.sqlwarn[9] 
#define      SQLWARNA  sqlca.sqlwarn[10] 
#define      SQLSTATE  sqlca.sqlstate 
#endif 
struct sqlca sqlca; 

/********************************************/ 

FILE   *logfp; 
int    sql_err(); 
int    call_sqlca_flags (); 
/*******************************************************************/ 
/*******************************************************************/ 
/*                         Main program                            */ 
/*******************************************************************/ 
/*******************************************************************/ 
int fmt_clnt() 
{         
   int i = 1; 
   int status = 0; 
   logfp = fopen("format.txt", "w"); 
   fprintf(logfp, "fmt_clnt version is HY2009Q4\n"); 
   strcpy(frm_batch_str, " "); 
   /****************************************************/ 
   /* get batch number from Forms program              */ 
   /****************************************************/ 
   /* exec iaf get reqdata.batch into :frm_batch_str;  */ 
   /* exec tools get reqdata.batch into :frm_batch_str; */ 

{ 
   struct sqlexd sqlstm; 
   sqlstm.sqlvsn = 10; 
   sqlstm.arrsiz = 2; 
   sqlstm.sqladtp = &sqladt; 
   sqlstm.sqltdsp = &sqltds; 
   sqlstm.stmt = ""; 
   sqlstm.iters = (unsigned int  )1; 
   sqlstm.offset = (unsigned int  )5; 
   sqlstm.cud = sqlcud0; 
   sqlstm.sqlest = (unsigned char  *)&sqlca; 
   sqlstm.sqlety = (unsigned short)256; 
   sqlstm.occurs = (unsigned int  )0; 
   sqlstm.sqhstv[0] = (         void  *)sqh000; 
   sqlstm.sqhstl[0] = (unsigned int  )13; 
   sqlstm.sqhsts[0] = (         int  )0; 
   sqlstm.sqindv[0] = (         void  *)0; 
   sqlstm.sqinds[0] = (         int  )0; 
   sqlstm.sqharm[0] = (unsigned int  )0; 
   sqlstm.sqadto[0] = (unsigned short )0; 
   sqlstm.sqtdso[0] = (unsigned short )0; 
   sqlstm.sqhstv[1] = (         void  *)frm_batch_str; 
   sqlstm.sqhstl[1] = (unsigned int  )10; 
   sqlstm.sqhsts[1] = (         int  )0; 
   sqlstm.sqindv[1] = (         void  *)0; 
   sqlstm.sqinds[1] = (         int  )0; 
   sqlstm.sqharm[1] = (unsigned int  )0; 
   sqlstm.sqadto[1] = (unsigned short )0; 
   sqlstm.sqtdso[1] = (unsigned short )0; 
   sqlstm.sqphsv = sqlstm.sqhstv; 
   sqlstm.sqphsl = sqlstm.sqhstl; 
   sqlstm.sqphss = sqlstm.sqhsts; 
   sqlstm.sqpind = sqlstm.sqindv; 
   sqlstm.sqpins = sqlstm.sqinds; 
   sqlstm.sqparm = sqlstm.sqharm; 
   sqlstm.sqparc = sqlstm.sqharc; 
   sqlstm.sqpadto = sqlstm.sqadto; 
   sqlstm.sqptdso = sqlstm.sqtdso; 
   sqlcxt((void **)0, &sqlctx, &sqlstm, &sqlfpn); 
} 


   /*****************************************************/ 
   /* Make sure dbms is accessible                      */ 
   /*****************************************************/ 
   /* exec sql whenever sqlerror do sql_err("Debug 1\n"); */ 

   /* exec sql select max(batch) into :todays_batch from bill_test; */ 

{ 
   struct sqlexd sqlstm; 
   sqlstm.sqlvsn = 10; 
   sqlstm.arrsiz = 2; 
   sqlstm.sqladtp = &sqladt; 
   sqlstm.sqltdsp = &sqltds; 
   sqlstm.stmt = "select max(batch) into :b0  from bill_test "; 
   sqlstm.iters = (unsigned int  )1; 
   sqlstm.offset = (unsigned int  )28; 
   sqlstm.selerr = (unsigned short)1; 
   sqlstm.cud = sqlcud0; 
   sqlstm.sqlest = (unsigned char  *)&sqlca; 
   sqlstm.sqlety = (unsigned short)256; 
   sqlstm.occurs = (unsigned int  )0; 
   sqlstm.sqhstv[0] = (         void  *)&todays_batch; 
   sqlstm.sqhstl[0] = (unsigned int  )sizeof(long); 
   sqlstm.sqhsts[0] = (         int  )0; 
   sqlstm.sqindv[0] = (         void  *)0; 
   sqlstm.sqinds[0] = (         int  )0; 
   sqlstm.sqharm[0] = (unsigned int  )0; 
   sqlstm.sqadto[0] = (unsigned short )0; 
   sqlstm.sqtdso[0] = (unsigned short )0; 
   sqlstm.sqphsv = sqlstm.sqhstv; 
   sqlstm.sqphsl = sqlstm.sqhstl; 
   sqlstm.sqphss = sqlstm.sqhsts; 
   sqlstm.sqpind = sqlstm.sqindv; 
   sqlstm.sqpins = sqlstm.sqinds; 
   sqlstm.sqparm = sqlstm.sqharm; 
   sqlstm.sqparc = sqlstm.sqharc; 
   sqlstm.sqpadto = sqlstm.sqadto; 
   sqlstm.sqptdso = sqlstm.sqtdso; 
   sqlcxt((void **)0, &sqlctx, &sqlstm, &sqlfpn); 
   if (sqlca.sqlcode < 0) sql_err("Debug 1\n"); 
} 


   fprintf(logfp, "High batch is %d\n", todays_batch); 
/*******************************************************************/ 
/*******************************************************************/ 
/*                         For Loop Debug                          */ 
/*******************************************************************/ 
/*******************************************************************/ 
   fprintf(logfp, "Only 8 entries in table but will loop forever\n"); 
   fprintf(logfp, "For (;;) loop change to max 20 to force breaking out\n"); 
   /* exec sql declare c1 cursor for 
       select sub_code, description from submission_code where 1=1 order by sub_code; */ 

   /* exec sql OPEN c1; */ 

{ 
   struct sqlexd sqlstm; 
   sqlstm.sqlvsn = 10; 
   sqlstm.arrsiz = 2; 
   sqlstm.sqladtp = &sqladt; 
   sqlstm.sqltdsp = &sqltds; 
   sqlstm.stmt = sq0003; 
   sqlstm.iters = (unsigned int  )1; 
   sqlstm.offset = (unsigned int  )47; 
   sqlstm.selerr = (unsigned short)1; 
   sqlstm.cud = sqlcud0; 
   sqlstm.sqlest = (unsigned char  *)&sqlca; 
   sqlstm.sqlety = (unsigned short)256; 
   sqlstm.occurs = (unsigned int  )0; 
   sqlcxt((void **)0, &sqlctx, &sqlstm, &sqlfpn); 
   if (sqlca.sqlcode < 0) sql_err("Debug 1\n"); 
} 


   /* exec sql whenever not found do break; */ 

   for (i; i < 20 ; ++ i) 
      { 
      /* exec sql fetch c1 into :sub_code, :description; */ 

{ 
      struct sqlexd sqlstm; 
      sqlstm.sqlvsn = 10; 
      sqlstm.arrsiz = 2; 
      sqlstm.sqladtp = &sqladt; 
      sqlstm.sqltdsp = &sqltds; 
      sqlstm.iters = (unsigned int  )1; 
      sqlstm.offset = (unsigned int  )62; 
      sqlstm.selerr = (unsigned short)1; 
      sqlstm.cud = sqlcud0; 
      sqlstm.sqlest = (unsigned char  *)&sqlca; 
      sqlstm.sqlety = (unsigned short)256; 
      sqlstm.occurs = (unsigned int  )0; 
      sqlstm.sqhstv[0] = (         void  *)sub_code; 
      sqlstm.sqhstl[0] = (unsigned int  )2; 
      sqlstm.sqhsts[0] = (         int  )0; 
      sqlstm.sqindv[0] = (         void  *)0; 
      sqlstm.sqinds[0] = (         int  )0; 
      sqlstm.sqharm[0] = (unsigned int  )0; 
      sqlstm.sqadto[0] = (unsigned short )0; 
      sqlstm.sqtdso[0] = (unsigned short )0; 
      sqlstm.sqhstv[1] = (         void  *)description; 
      sqlstm.sqhstl[1] = (unsigned int  )61; 
      sqlstm.sqhsts[1] = (         int  )0; 
      sqlstm.sqindv[1] = (         void  *)0; 
      sqlstm.sqinds[1] = (         int  )0; 
      sqlstm.sqharm[1] = (unsigned int  )0; 
      sqlstm.sqadto[1] = (unsigned short )0; 
      sqlstm.sqtdso[1] = (unsigned short )0; 
      sqlstm.sqphsv = sqlstm.sqhstv; 
      sqlstm.sqphsl = sqlstm.sqhstl; 
      sqlstm.sqphss = sqlstm.sqhsts; 
      sqlstm.sqpind = sqlstm.sqindv; 
      sqlstm.sqpins = sqlstm.sqinds; 
      sqlstm.sqparm = sqlstm.sqharm; 
      sqlstm.sqparc = sqlstm.sqharc; 
      sqlstm.sqpadto = sqlstm.sqadto; 
      sqlstm.sqptdso = sqlstm.sqtdso; 
      sqlcxt((void **)0, &sqlctx, &sqlstm, &sqlfpn); 
      if (sqlca.sqlcode == 1403) break; 
      if (sqlca.sqlcode < 0) sql_err("Debug 1\n"); 
} 


      fprintf(logfp, "When i=%d sqlcode=%d sub_code=%s desc=%s\n", i,sqlca.sqlcode,sub_code,description);  
      } 
   /* exec sql CLOSE c1; */ 

{ 
   struct sqlexd sqlstm; 
   sqlstm.sqlvsn = 10; 
   sqlstm.arrsiz = 2; 
   sqlstm.sqladtp = &sqladt; 
   sqlstm.sqltdsp = &sqltds; 
   sqlstm.iters = (unsigned int  )1; 
   sqlstm.offset = (unsigned int  )85; 
   sqlstm.cud = sqlcud0; 
   sqlstm.sqlest = (unsigned char  *)&sqlca; 
   sqlstm.sqlety = (unsigned short)256; 
   sqlstm.occurs = (unsigned int  )0; 
   sqlcxt((void **)0, &sqlctx, &sqlstm, &sqlfpn); 
   if (sqlca.sqlcode < 0) sql_err("Debug 1\n"); 
} 


/*******************************************************************/ 
/*******************************************************************/ 
/*******************************************************************/ 
/*                       End For Loop Debug                        */ 
/*******************************************************************/ 
/*******************************************************************/ 
   if (status == HYFAILED || status == IAPFAIL)  
      return (IAPFAIL); 
   fclose(logfp); 
   return (IAPSUCC); 
} 
/*******************************************************************/ 
/*******************************************************************/ 
/*                       SQL_ERR trapping                          */ 
/*******************************************************************/ 
/*******************************************************************/ 
int sql_err(msg) 
char *msg; 
{ 
char err_msg[128]; 
int  msg_len;     
/*hy   strcpy (err_msg, sqlca.sqlerrm.sqlerrmc);  */ 
   msg_len = strlen (err_msg); 
   fprintf(logfp, "error %s\n", err_msg); 
   /* exec sql ROLLBACK; */ 

{ 
   struct sqlexd sqlstm; 
   sqlstm.sqlvsn = 10; 
   sqlstm.arrsiz = 2; 
   sqlstm.sqladtp = &sqladt; 
   sqlstm.sqltdsp = &sqltds; 
   sqlstm.iters = (unsigned int  )1; 
   sqlstm.offset = (unsigned int  )100; 
   sqlstm.cud = sqlcud0; 
   sqlstm.sqlest = (unsigned char  *)&sqlca; 
   sqlstm.sqlety = (unsigned short)256; 
   sqlstm.occurs = (unsigned int  )0; 
   sqlcxt((void **)0, &sqlctx, &sqlstm, &sqlfpn); 
   if (sqlca.sqlcode < 0) sql_err("Debug 1\n"); 
} 


   return (IAPFAIL); 
} 
/*******************************************************************/ 
/*******************************************************************/ 

fmt_clnt version is HY2009Q4 
High batch is 20091224 
Only 8 entries in table but will loop forever 
For (;;) loop change to max 20 to force breaking out 
When i=1 sqlcode=0 sub_code=0 desc=Normal submission                                           
When i=2 sqlcode=0 sub_code=A desc=Requested pre-approval claim                                
When i=3 sqlcode=0 sub_code=C desc=Subscriber coverage problem                                 
When i=4 sqlcode=0 sub_code=D desc=Duplicate claim                                             
When i=5 sqlcode=0 sub_code=I desc=ICBC claim                                                  
When i=6 sqlcode=0 sub_code=R desc=Re-submitted claim                   

3 个答案:

答案 0 :(得分:0)

我知道零Pro * C,但我相信最普遍接受的语法是这个

EXEC SQL WHENEVER NOT FOUND DO break;
for(;;)
  //statement
EXEC SQL WHENEVER NOT FOUND CONTINUE;

此外,在检查 not found 值时,我通常会检查sqlcode 100,而不是1403.我不确定区别是什么,但我已经看到了。

答案 1 :(得分:0)

在原始的fmt_clnt.pc文件中,您有以下代码:

/* exec sql INCLUDE sqlca; */ 

此代码应删除并替换为:

#include <sqlca.h>

文件中的代码是围绕以前的版本构建的,可能会对结构进行细微的更改。当您从一个主要版本转到另一个主要版本或Oracle时,尤其如此。

答案 2 :(得分:0)

对于那些仍然感兴趣的人: 我终于通过构建一个干净的PC然后安装旧版本的预编译器来解决这个问题。 比较2个输出似乎sqlca.sqlcode的数据类型导致了问题。 Pro c ver 2.2 sqlcode很长,而pro c ver 9.0是整数。这可以解释为什么我总是得到归零。 感谢所有贡献者。