Mapper
get_sensor_list.c
Go to the documentation of this file.
1 #include <sqlhdr.h>
2 #include <sqliapi.h>
3 static const char _Cn1[] = "sensorcursor";
4 #line 1 "get_sensor_list.ec"
5 #include "prototypes_new.h"
6 /*
7  * EXEC SQL include sqlca.h;
8  */
9 #line 2 "get_sensor_list.ec"
10 
11 #line 2 "get_sensor_list.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_sensor_list.ec"
118 int get_sensor_list(char *hb5,struct sens_rec *sens_record)
119 
120 {
121 
122 int i,j;
123 extern int dbase;
124 
125 /*
126  * EXEC SQL BEGIN DECLARE SECTION;
127  */
128 #line 10 "get_sensor_list.ec"
129 #line 11 "get_sensor_list.ec"
130 extern char astring[50];
131 extern struct eens_rec
132  {
133  char id[6];
134  char pe1[2];
135  char pe2[2];
136  char dur[2];
137  char t[2];
138  char s[2];
139  char e[2];
140  char p[2];
141  char type[2];
142  char des[51];
143  char det[41];
144  int post;
145  char new_report[2];
146  char active[2];
147  char rfs[2];
148  int obstime;
149  char prod[10];
150  char prod2ary[10];
151  char obsag[7];
152  char obsloc[4];
153  char prov_avail[2];
154  char final_avail[8];
155  char ownag[7];
156  char ownloc[4];
157  char maintag[7];
158  char maintloc[4];
159  char init[9];
160  char dbsource[4];
161  } bens_rec;
162 /*
163  * EXEC SQL END DECLARE SECTION;
164  */
165 #line 45 "get_sensor_list.ec"
166 
167 
168 strcpy(astring,hb5);
169 
170 i=0;
171 while(astring[i] != 0)
172  astring[i++]=toupper(astring[i]);
173 
174 /*
175  * EXEC SQL open sensorcursor using: astring;
176  */
177 #line 53 "get_sensor_list.ec"
178  {
179 #line 53 "get_sensor_list.ec"
180  static ifx_sqlvar_t _sqibind[] =
181  {
182  { 100, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
183 #line 53 "get_sensor_list.ec"
184  };
185  static ifx_sqlda_t _SD0 = { 1, _sqibind, {0}, 1, 0 };
186 #line 53 "get_sensor_list.ec"
187  _sqibind[0].sqldata = astring;
188  sqli_curs_open(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, _Cn1, 768), &_SD0, (char *)0, (struct value *)0, 1, 0);
189 #line 53 "get_sensor_list.ec"
190  }
191 
192 if(sqlca.sqlcode < 0)
193  return(sqlca.sqlcode);
194 
195 j=0;
196  for(i=0;i<100;i++) {
197 
198 /*
199  * EXEC SQL fetch sensorcursor into :bens_rec;
200  */
201 #line 61 "get_sensor_list.ec"
202  {
203 #line 61 "get_sensor_list.ec"
204  static ifx_sqlvar_t _sqobind[] =
205  {
206  { 100, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
207  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
208  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
209  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
210  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
211  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
212  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
213  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
214  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
215  { 100, 51, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
216  { 100, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
217  { 102, sizeof((bens_rec).post), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
218  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
219  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
220  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
221  { 102, sizeof((bens_rec).obstime), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
222  { 100, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
223  { 100, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
224  { 100, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
225  { 100, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
226  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
227  { 100, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
228  { 100, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
229  { 100, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
230  { 100, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
231  { 100, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
232  { 100, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
233  { 100, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
234 #line 61 "get_sensor_list.ec"
235  };
236  static ifx_sqlda_t _SD0 = { 28, _sqobind, {0}, 28, 0 };
237  static _FetchSpec _FS1 = { 0, 1, 0 };
238 #line 61 "get_sensor_list.ec"
239  _sqobind[0].sqldata = (bens_rec).id;
240 #line 61 "get_sensor_list.ec"
241  _sqobind[1].sqldata = (bens_rec).pe1;
242 #line 61 "get_sensor_list.ec"
243  _sqobind[2].sqldata = (bens_rec).pe2;
244 #line 61 "get_sensor_list.ec"
245  _sqobind[3].sqldata = (bens_rec).dur;
246 #line 61 "get_sensor_list.ec"
247  _sqobind[4].sqldata = (bens_rec).t;
248 #line 61 "get_sensor_list.ec"
249  _sqobind[5].sqldata = (bens_rec).s;
250 #line 61 "get_sensor_list.ec"
251  _sqobind[6].sqldata = (bens_rec).e;
252 #line 61 "get_sensor_list.ec"
253  _sqobind[7].sqldata = (bens_rec).p;
254 #line 61 "get_sensor_list.ec"
255  _sqobind[8].sqldata = (bens_rec).type;
256 #line 61 "get_sensor_list.ec"
257  _sqobind[9].sqldata = (bens_rec).des;
258 #line 61 "get_sensor_list.ec"
259  _sqobind[10].sqldata = (bens_rec).det;
260 #line 61 "get_sensor_list.ec"
261  _sqobind[11].sqldata = (char *) &(bens_rec).post;
262 #line 61 "get_sensor_list.ec"
263  _sqobind[12].sqldata = (bens_rec).new_report;
264 #line 61 "get_sensor_list.ec"
265  _sqobind[13].sqldata = (bens_rec).active;
266 #line 61 "get_sensor_list.ec"
267  _sqobind[14].sqldata = (bens_rec).rfs;
268 #line 61 "get_sensor_list.ec"
269  _sqobind[15].sqldata = (char *) &(bens_rec).obstime;
270 #line 61 "get_sensor_list.ec"
271  _sqobind[16].sqldata = (bens_rec).prod;
272 #line 61 "get_sensor_list.ec"
273  _sqobind[17].sqldata = (bens_rec).prod2ary;
274 #line 61 "get_sensor_list.ec"
275  _sqobind[18].sqldata = (bens_rec).obsag;
276 #line 61 "get_sensor_list.ec"
277  _sqobind[19].sqldata = (bens_rec).obsloc;
278 #line 61 "get_sensor_list.ec"
279  _sqobind[20].sqldata = (bens_rec).prov_avail;
280 #line 61 "get_sensor_list.ec"
281  _sqobind[21].sqldata = (bens_rec).final_avail;
282 #line 61 "get_sensor_list.ec"
283  _sqobind[22].sqldata = (bens_rec).ownag;
284 #line 61 "get_sensor_list.ec"
285  _sqobind[23].sqldata = (bens_rec).ownloc;
286 #line 61 "get_sensor_list.ec"
287  _sqobind[24].sqldata = (bens_rec).maintag;
288 #line 61 "get_sensor_list.ec"
289  _sqobind[25].sqldata = (bens_rec).maintloc;
290 #line 61 "get_sensor_list.ec"
291  _sqobind[26].sqldata = (bens_rec).init;
292 #line 61 "get_sensor_list.ec"
293  _sqobind[27].sqldata = (bens_rec).dbsource;
294  sqli_curs_fetch(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, _Cn1, 768), (ifx_sqlda_t *)0, &_SD0, (char *)0, &_FS1);
295 #line 61 "get_sensor_list.ec"
296  }
297 
298  if(sqlca.sqlcode < 0)
299  return(sqlca.sqlcode);
300 
301  if(sqlca.sqlcode != 0)
302  break;
303 /*
304 
305  if(dbase==1 || dbase==2) {
306 
307  if(bens_rec.dur[0] != 'H' ||
308  bens_rec.dur[0] != 'Q' ||
309 
310  if(dbase==3 && bens_rec.dur[0] != 'D')
311  continue;
312 
313  if(dbase==4 && bens_rec.dur[0] != 'M')
314  continue;
315 */
316 
317  memcpy(&sens_record[j],&bens_rec,sizeof(struct eens_rec));
318  j++;
319 
320  }
321 
322 /*
323  * EXEC SQL close sensorcursor;
324  */
325 #line 87 "get_sensor_list.ec"
326  {
327 #line 87 "get_sensor_list.ec"
328  sqli_curs_close(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, _Cn1, 768));
329 #line 87 "get_sensor_list.ec"
330  }
331 
332 return(j);
333 
334 
335 }
336 
337 
338 
339 
340 
341 #line 96 "get_sensor_list.ec"
static int i
long SQLCODE
struct sqlca_s sqlca
int get_sensor_list(char *hb5, struct sens_rec *sens_record)
char astring[50]
int rfs(int)
static const char _Cn1[]
struct sqlca_s ifx_sqlca_t
char SQLSTATE[]
int j
Definition: mapp2h.h:48
struct database dbase
Definition: mapper.c:121
float value
Definition: misc.h:155
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