Mapper
get_bad_recs.c
Go to the documentation of this file.
1 #include <sqlhdr.h>
2 #include <sqliapi.h>
3 static const char _Cn1[] = "cfok";
4 #line 1 "get_bad_recs.ec"
5 #include "prototypes_new.h"
6 /*
7  * EXEC SQL include sqlca.h;
8  */
9 #line 2 "get_bad_recs.ec"
10 
11 #line 2 "get_bad_recs.ec"
12 #line 1 "/opt/informix/incl/esql/sqlca.h"
13 /****************************************************************************
14  *
15  * Licensed Material - Property Of IBM
16  *
17  * "Restricted Materials of IBM"
18  *
19  * IBM Informix Client SDK
20  * Copyright IBM Corporation 1997, 2008. All rights reserved.
21  *
22  * Title: sqlca.h
23  * Description: SQL Control Area
24  *
25  ***************************************************************************
26  */
27 
28 #ifndef SQLCA_INCL
29 #define SQLCA_INCL
30 
31 #include "ifxtypes.h"
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
37 typedef struct sqlca_s
38  {
39  int4 sqlcode;
40 #ifdef DB2CLI
41  char sqlerrm[600]; /* error message parameters */
42 #else /* DB2CLI */
43  char sqlerrm[72]; /* error message parameters */
44 #endif /* DB2CLI */
45  char sqlerrp[8];
46  int4 sqlerrd[6];
47  /* 0 - estimated number of rows returned */
48  /* 1 - serial value after insert or ISAM error code */
49  /* 2 - number of rows processed */
50  /* 3 - estimated cost */
51  /* 4 - offset of the error into the SQL statement */
52  /* 5 - rowid after insert */
53 #ifdef _FGL_
54  char sqlawarn[8];
55 #else
56  struct sqlcaw_s
57  {
58  char sqlwarn0; /* = W if any of sqlwarn[1-7] = W */
59  char sqlwarn1; /* = W if any truncation occurred or
60  database has transactions or
61  no privileges revoked */
62  char sqlwarn2; /* = W if a null value returned or
63  ANSI database */
64  char sqlwarn3; /* = W if no. in select list != no. in into list or
65  turbo backend or no privileges granted */
66  char sqlwarn4; /* = W if no where clause on prepared update, delete or
67  incompatible float format */
68  char sqlwarn5; /* = W if non-ANSI statement */
69  char sqlwarn6; /* = W if server is in data replication secondary mode */
70  char sqlwarn7; /* = W if database locale is different from proc_locale
71  = W if backend XPS and if explain avoid_execute is set
72  (for select, insert, delete and update only)
73  */
74  } sqlwarn;
75 #endif
77 
78 /* NOTE: 4gl assumes that the sqlwarn structure can be defined as
79  * sqlawarn -- an 8 character string, because single-char
80  * variables are not recognized in 4gl.
81  *
82  * If this structure should change, the code generated by 4gl compiler
83  * must also change
84  */
85 
86 #define SQLNOTFOUND 100
87 
88 #ifndef IFX_THREAD
89 #ifdef DB2CLI
90 #define sqlca ifmxsqlca
91 extern struct sqlca_s sqlca;
92 #else /* DB2CLI */
93 extern struct sqlca_s sqlca;
94 #endif /* DB2CLI */
95 
96 #ifndef DRDAHELP
97 extern int4 SQLCODE;
98 #endif
99 
100 extern char SQLSTATE[];
101 #else /* IFX_THREAD */
102 extern int4 * ifx_sqlcode(void);
103 extern struct sqlca_s * ifx_sqlca(void);
104 /* ifx_sqlstate() declared in sqlhdr.h */
105 #define SQLCODE (*(ifx_sqlcode()))
106 #define SQLSTATE ((char *)(ifx_sqlstate()))
107 #define sqlca (*(ifx_sqlca()))
108 #endif /* IFX_THREAD */
109 
110 #ifdef __cplusplus
111 }
112 #endif
113 
114 #endif /* SQLCA_INCL */
115 
116 #line 103 "/opt/informix/incl/esql/sqlca.h"
117 #line 3 "get_bad_recs.ec"
118 
119 int get_bad_recs(char *hb5,char *ped,struct sens_ok *ok_rec)
120 
121 
122 {
123 
124 /*
125  * EXEC SQL BEGIN DECLARE SECTION;
126  */
127 #line 9 "get_bad_recs.ec"
128 #line 10 "get_bad_recs.ec"
129  char id[6], pe1[2], pe2[2], dur[2], t[2], s[2], e[2], p[2];
130 struct sens_ok_rec
131  {
132  char tid[6];
133  char tpe1[2];
134  char tpe2[2];
135  char tdur[2];
136  char tt[2];
137  char ts[2];
138  char te[2];
139  char tp[2];
140  int cal_yr;
141  int mon;
142  int zday;
143  int ztime;
144  char tok[2];
145  char reason[81];
146  char init[4];
147  char agcode[7];
148  char agloc[4];
149  char comment[41];
150  } sok;
151 /*
152  * EXEC SQL END DECLARE SECTION;
153  */
154 #line 35 "get_bad_recs.ec"
155 
156 
157 int i,totnum;
158 
159 pe1[1]=pe2[1]=dur[1]=t[1]=s[1]=e[1]=p[1]=0;
160 
161 strcpy(id,hb5);
162 
163 pe1[0]=ped[0];
164 pe2[0]=ped[1];
165 dur[0]=ped[2];
166 t[0]=ped[3];
167 s[0]=ped[4];
168 e[0]=ped[5];
169 p[0]=ped[6];
170 
171 /*
172  * EXEC SQL open cfok using :id,:pe1,:pe2,:dur,:t,:s,:e,:p;
173  */
174 #line 51 "get_bad_recs.ec"
175  {
176 #line 51 "get_bad_recs.ec"
177  static ifx_sqlvar_t _sqibind[] =
178  {
179  { 100, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
180  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
181  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
182  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
183  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
184  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
185  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
186  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
187 #line 51 "get_bad_recs.ec"
188  };
189  static ifx_sqlda_t _SD0 = { 8, _sqibind, {0}, 8, 0 };
190 #line 51 "get_bad_recs.ec"
191  _sqibind[0].sqldata = id;
192 #line 51 "get_bad_recs.ec"
193  _sqibind[1].sqldata = pe1;
194 #line 51 "get_bad_recs.ec"
195  _sqibind[2].sqldata = pe2;
196 #line 51 "get_bad_recs.ec"
197  _sqibind[3].sqldata = dur;
198 #line 51 "get_bad_recs.ec"
199  _sqibind[4].sqldata = t;
200 #line 51 "get_bad_recs.ec"
201  _sqibind[5].sqldata = s;
202 #line 51 "get_bad_recs.ec"
203  _sqibind[6].sqldata = e;
204 #line 51 "get_bad_recs.ec"
205  _sqibind[7].sqldata = p;
206  sqli_curs_open(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, _Cn1, 768), &_SD0, (char *)0, (struct value *)0, 1, 0);
207 #line 51 "get_bad_recs.ec"
208  }
209 
210 if (sqlca.sqlcode < 0){
211 
212  printf("informix error %d\n", sqlca.sqlcode);
213  exit(1);
214 }
215 
216 totnum=0;
217 
218 for(i=0;i<100;i++) {
219 
220 /*
221  * EXEC SQL fetch cfok into : sok;
222  */
223 #line 63 "get_bad_recs.ec"
224  {
225 #line 63 "get_bad_recs.ec"
226  static ifx_sqlvar_t _sqobind[] =
227  {
228  { 100, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
229  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
230  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
231  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
232  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
233  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
234  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
235  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
236  { 102, sizeof((sok).cal_yr), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
237  { 102, sizeof((sok).mon), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
238  { 102, sizeof((sok).zday), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
239  { 102, sizeof((sok).ztime), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
240  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
241  { 100, 81, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
242  { 100, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
243  { 100, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
244  { 100, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
245  { 100, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
246 #line 63 "get_bad_recs.ec"
247  };
248  static ifx_sqlda_t _SD0 = { 18, _sqobind, {0}, 18, 0 };
249  static _FetchSpec _FS1 = { 0, 1, 0 };
250 #line 63 "get_bad_recs.ec"
251  _sqobind[0].sqldata = (sok).tid;
252 #line 63 "get_bad_recs.ec"
253  _sqobind[1].sqldata = (sok).tpe1;
254 #line 63 "get_bad_recs.ec"
255  _sqobind[2].sqldata = (sok).tpe2;
256 #line 63 "get_bad_recs.ec"
257  _sqobind[3].sqldata = (sok).tdur;
258 #line 63 "get_bad_recs.ec"
259  _sqobind[4].sqldata = (sok).tt;
260 #line 63 "get_bad_recs.ec"
261  _sqobind[5].sqldata = (sok).ts;
262 #line 63 "get_bad_recs.ec"
263  _sqobind[6].sqldata = (sok).te;
264 #line 63 "get_bad_recs.ec"
265  _sqobind[7].sqldata = (sok).tp;
266 #line 63 "get_bad_recs.ec"
267  _sqobind[8].sqldata = (char *) &(sok).cal_yr;
268 #line 63 "get_bad_recs.ec"
269  _sqobind[9].sqldata = (char *) &(sok).mon;
270 #line 63 "get_bad_recs.ec"
271  _sqobind[10].sqldata = (char *) &(sok).zday;
272 #line 63 "get_bad_recs.ec"
273  _sqobind[11].sqldata = (char *) &(sok).ztime;
274 #line 63 "get_bad_recs.ec"
275  _sqobind[12].sqldata = (sok).tok;
276 #line 63 "get_bad_recs.ec"
277  _sqobind[13].sqldata = (sok).reason;
278 #line 63 "get_bad_recs.ec"
279  _sqobind[14].sqldata = (sok).init;
280 #line 63 "get_bad_recs.ec"
281  _sqobind[15].sqldata = (sok).agcode;
282 #line 63 "get_bad_recs.ec"
283  _sqobind[16].sqldata = (sok).agloc;
284 #line 63 "get_bad_recs.ec"
285  _sqobind[17].sqldata = (sok).comment;
286  sqli_curs_fetch(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, _Cn1, 768), (ifx_sqlda_t *)0, &_SD0, (char *)0, &_FS1);
287 #line 63 "get_bad_recs.ec"
288  }
289 
290  if (sqlca.sqlcode < 0){
291 
292  printf("informix error %d\n", sqlca.sqlcode);
293  exit(1);
294 
295  }
296 
297  if(sqlca.sqlcode==100)
298  break;
299 
300  memcpy(&ok_rec[i],&sok,sizeof(struct sens_ok));
301 
302  totnum++;
303 
304 }
305 
306 /*
307  * EXEC SQL CLOSE cfok;
308  */
309 #line 81 "get_bad_recs.ec"
310  {
311 #line 81 "get_bad_recs.ec"
312  sqli_curs_close(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, _Cn1, 768));
313 #line 81 "get_bad_recs.ec"
314  }
315 
316 return(totnum);
317 
318 }
319 
320 #line 85 "get_bad_recs.ec"
static int i
static const char _Cn1[]
Definition: get_bad_recs.c:3
int4 SQLCODE
struct sqlca_s ifx_sqlca_t
char SQLSTATE[]
struct sqlca_s sqlca
int get_bad_recs(char *hb5, char *ped, struct sens_ok *ok_rec)
Definition: get_bad_recs.c:119
char * mon[]
printf("fbuf is %s\n", fbuf)
float value
int tid
Definition: shef_structs.h:258
Definition: misc.h:103
char sqlwarn5
Definition: db.c:65
char sqlwarn3
Definition: db.c:61
char sqlwarn4
Definition: db.c:63
char sqlwarn7
Definition: db.c:67
char sqlwarn1
Definition: db.c:57
char sqlwarn6
Definition: db.c:66
char sqlwarn2
Definition: db.c:59
char sqlwarn0
Definition: db.c:56
Definition: db.c:43
long sqlerrd[6]
Definition: db.c:47
struct sqlca_s::sqlcaw_s sqlwarn
long sqlcode
Definition: db.c:44
char sqlerrm[72]
Definition: db.c:45
char sqlerrp[8]
Definition: db.c:46
Definition: misc_new.h:35