Mapper
hb5_search.c
Go to the documentation of this file.
1 #include <sqlhdr.h>
2 #include <sqliapi.h>
3 static const char _Cn1[] = "hb5cursor";
4 #line 1 "hb5_search.ec"
5 #include "prototypes_new.h"
6 /*
7  * EXEC SQL include sqlca.h;
8  */
9 #line 2 "hb5_search.ec"
10 
11 #line 2 "hb5_search.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 "hb5_search.ec"
118 
119 
120 /*
121  * EXEC SQL BEGIN DECLARE SECTION;
122  */
123 #line 5 "hb5_search.ec"
124 #line 6 "hb5_search.ec"
125 extern char astring[50];
126 struct etn_rec
127  {
128  char id[6];
129  char plat[9];
130  char des[51];
131  char det[41];
132  char init[9];
133  char lat[7];
134  char lng[8];
135  int elev;
136  char stat[3];
137  char huc[9];
138  char cou[4];
139  char zon[5];
140  char hsa[4];
141  char cwa[4];
142  int post;
143  char dbsource[4];
145 /*
146  * EXEC SQL END DECLARE SECTION;
147  */
148 #line 30 "hb5_search.ec"
149 
150 
151 int hb5_search(int dbase,char *cstr,struct stn_rec *stn_record)
152 
153 {
154 
155 
156 int i;
157 
158 strcpy(astring,cstr);
159 
160 i=0;
161 while(astring[i] != 0)
162  astring[i++]=toupper(astring[i]);
163 
164 /*
165  * EXEC SQL open hb5cursor using: astring;
166  */
167 #line 45 "hb5_search.ec"
168  {
169 #line 45 "hb5_search.ec"
170  static ifx_sqlvar_t _sqibind[] =
171  {
172  { 100, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
173 #line 45 "hb5_search.ec"
174  };
175  static ifx_sqlda_t _SD0 = { 1, _sqibind, {0}, 1, 0 };
176 #line 45 "hb5_search.ec"
177  _sqibind[0].sqldata = astring;
178  sqli_curs_open(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, _Cn1, 768), &_SD0, (char *)0, (struct value *)0, 1, 0);
179 #line 45 "hb5_search.ec"
180  }
181 
182 if(sqlca.sqlcode !=0 )
183  return(sqlca.sqlcode);
184 
185 for(i=0;i<500;i++) {
186 
187 /*
188  * EXEC SQL fetch hb5cursor into :btn_rec;
189  */
190 #line 52 "hb5_search.ec"
191  {
192 #line 52 "hb5_search.ec"
193  static ifx_sqlvar_t _sqobind[] =
194  {
195  { 100, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
196  { 100, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
197  { 100, 51, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
198  { 100, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
199  { 100, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
200  { 100, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
201  { 100, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
202  { 102, sizeof((btn_rec).elev), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
203  { 100, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
204  { 100, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
205  { 100, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
206  { 100, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
207  { 100, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
208  { 100, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
209  { 102, sizeof((btn_rec).post), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
210  { 100, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
211 #line 52 "hb5_search.ec"
212  };
213  static ifx_sqlda_t _SD0 = { 16, _sqobind, {0}, 16, 0 };
214  static _FetchSpec _FS1 = { 0, 1, 0 };
215 #line 52 "hb5_search.ec"
216  _sqobind[0].sqldata = (btn_rec).id;
217 #line 52 "hb5_search.ec"
218  _sqobind[1].sqldata = (btn_rec).plat;
219 #line 52 "hb5_search.ec"
220  _sqobind[2].sqldata = (btn_rec).des;
221 #line 52 "hb5_search.ec"
222  _sqobind[3].sqldata = (btn_rec).det;
223 #line 52 "hb5_search.ec"
224  _sqobind[4].sqldata = (btn_rec).init;
225 #line 52 "hb5_search.ec"
226  _sqobind[5].sqldata = (btn_rec).lat;
227 #line 52 "hb5_search.ec"
228  _sqobind[6].sqldata = (btn_rec).lng;
229 #line 52 "hb5_search.ec"
230  _sqobind[7].sqldata = (char *) &(btn_rec).elev;
231 #line 52 "hb5_search.ec"
232  _sqobind[8].sqldata = (btn_rec).stat;
233 #line 52 "hb5_search.ec"
234  _sqobind[9].sqldata = (btn_rec).huc;
235 #line 52 "hb5_search.ec"
236  _sqobind[10].sqldata = (btn_rec).cou;
237 #line 52 "hb5_search.ec"
238  _sqobind[11].sqldata = (btn_rec).zon;
239 #line 52 "hb5_search.ec"
240  _sqobind[12].sqldata = (btn_rec).hsa;
241 #line 52 "hb5_search.ec"
242  _sqobind[13].sqldata = (btn_rec).cwa;
243 #line 52 "hb5_search.ec"
244  _sqobind[14].sqldata = (char *) &(btn_rec).post;
245 #line 52 "hb5_search.ec"
246  _sqobind[15].sqldata = (btn_rec).dbsource;
247  sqli_curs_fetch(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, _Cn1, 768), (ifx_sqlda_t *)0, &_SD0, (char *)0, &_FS1);
248 #line 52 "hb5_search.ec"
249  }
250 
251  if(sqlca.sqlcode < 0)
252  return(sqlca.sqlcode);
253 
254  if(sqlca.sqlcode != 0)
255  break;
256 
257  memcpy(&stn_record[i],&btn_rec,sizeof(struct stn_rec));
258 
259  }
260 
261 /*
262  * EXEC SQL close hb5cursor;
263  */
264 #line 64 "hb5_search.ec"
265  {
266 #line 64 "hb5_search.ec"
267  sqli_curs_close(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, _Cn1, 768));
268 #line 64 "hb5_search.ec"
269  }
270 
271 return(i);
272 
273 }
274 
275 
276 
277 
278 #line 71 "hb5_search.ec"
static int i
long SQLCODE
int hb5_search(int dbase, char *cstr, struct stn_rec *stn_record)
Definition: hb5_search.c:125
char astring[50]
struct sqlca_s sqlca
struct etn_rec btn_rec
static const char _Cn1[]
Definition: hb5_search.c:3
struct sqlca_s ifx_sqlca_t
char SQLSTATE[]
int elev
Definition: mapp2h.h:48
double lat
Definition: mapp2h.h:41
struct database dbase
Definition: mapper.c:121
float value
char huc[9]
Definition: hb5_search.c:137
char det[41]
Definition: hb5_search.c:104
char cwa[4]
Definition: hb5_search.c:141
char hsa[4]
Definition: hb5_search.c:140
char init[9]
Definition: hb5_search.c:105
int elev
Definition: hb5_search.c:108
char plat[9]
Definition: hb5_search.c:99
char des[51]
Definition: hb5_search.c:103
char lng[8]
Definition: hb5_search.c:107
char lat[7]
Definition: hb5_search.c:106
char cou[4]
Definition: hb5_search.c:111
char zon[5]
Definition: hb5_search.c:112
int post
Definition: hb5_search.c:117
char dbsource[4]
Definition: hb5_search.c:143
char stat[3]
Definition: hb5_search.c:109
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.h:135