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