Oracle预编译器dll库

发布于 2024-08-16 18:17:01 字数 26444 浏览 3 评论 0原文

平台:运行Oracle 10g的Windows

我必须修改一些旧的dll库代码并用Oracle预编译 Pro*C/C++ 9.0.1.1.1,现在我发现了代码 for(;;) 每当找不到 do break 时就不再起作用,它只是保持 循环播放。 我在这里准备了一些代码,显示预编译之前和之后的情况 也是一个日志。 预先感谢任何能够提供帮助的人。

(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                   

Platform : Windows running Oracle 10g

I have to modify some old dll library codes and precompile with Oracle
Pro*C/C++ 9.0.1.1.1, now I discovered the codes
for(;;) whenever not found do break is no longer working, it just keep
looping.
I have prepared some codes here showing before and after precompile and
also a log.
Thanks in advance to whoever might be able to help.

(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                   

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

善良天后 2024-08-23 18:17:01

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

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

此外,在检查 未找到 值时,我通常检查 sqlcode 100,而不是 1403。我不确定区别在于,但我都见过。

I know zero Pro*C, but I believe the most commonly accepted syntax is this

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

Also, when checking for a not found value I normally check against sqlcode 100, not 1403. I'm not sure what the difference is, but I've seen both.

冷弦 2024-08-23 18:17:01

在原始的 fmt_clnt.pc 文件中,有一段代码如下:

/* exec sql INCLUDE sqlca; */ 

应删除此代码并将其替换为:

#include <sqlca.h>

文件中的代码是围绕以前的版本构建的,并且可能在结构上有细微的变化。当您从一个主要版本转到另一个主要版本或 Oracle 时尤其如此。

In your original fmt_clnt.pc file you have a chunk of code following:

/* exec sql INCLUDE sqlca; */ 

This code should be removed and replaced with:

#include <sqlca.h>

The code you have in the file is built around the previous version and may have subtle changes in the structures. This is especially true when you go from one major version to another or Oracle.

桃扇骨 2024-08-23 18:17:01

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

For those who are still interested:
I have finally resolved the issue by building a clean pc then installing an old version of the precompiler.
Comparing the 2 outputs it seems the datatype for the sqlca.sqlcode is causing the problem.
Proc ver 2.2 sqlcode is long while proc ver 9.0 is integer. This would explain why I was always getting a zero returned.
Thanks to all who contributed.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文