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