1
/* Processed by ecpg (regression mode) */
2
/* These include files are added by the preprocessor */
6
/* Needed for informix compatibility */
7
#include <ecpg_informix.h>
8
/* End of automatic include section */
9
#define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
11
#line 1 "test_informix2.pgc"
18
#ifndef POSTGRES_SQLCA_H
19
#define POSTGRES_SQLCA_H
22
#if defined(WIN32) || defined(__CYGWIN__)
23
#define PGDLLIMPORT __declspec (dllimport)
26
#endif /* __CYGWIN__ */
27
#endif /* PGDLLIMPORT */
29
#define SQLERRMC_LEN 150
44
char sqlerrmc[SQLERRMC_LEN];
48
/* Element 0: empty */
49
/* 1: OID of processed tuple if applicable */
50
/* 2: number of rows processed */
51
/* after an INSERT, UPDATE or */
52
/* DELETE statement */
57
/* Element 0: set to 'W' if at least one other is 'W' */
58
/* 1: if 'W' at least one character string */
59
/* value was truncated when it was */
60
/* stored into a host variable. */
63
* 2: if 'W' a (hopefully) non-fatal notice occurred
73
struct sqlca_t *ECPGget_sqlca(void);
75
#ifndef POSTGRES_ECPG_INTERNAL
76
#define sqlca (*ECPGget_sqlca())
85
#line 5 "test_informix2.pgc"
88
#line 1 "regression.h"
95
#line 6 "test_informix2.pgc"
99
/* Check SQLCODE, and produce a "standard error" if it's wrong! */
100
static void sql_check(char *fn, char *caller, int ignore)
102
char errorstring[255];
104
if (SQLCODE == ignore)
111
sprintf(errorstring, "**SQL error %ld doing '%s' in function '%s'. [%s]",
112
SQLCODE, caller, fn, sqlca.sqlerrm.sqlerrmc);
113
fprintf(stderr, "%s", errorstring);
114
printf("%s\n", errorstring);
116
/* attempt a ROLLBACK */
117
{ ECPGtrans(__LINE__, NULL, "rollback");}
118
#line 27 "test_informix2.pgc"
123
sprintf(errorstring, "Rollback successful.\n");
125
sprintf(errorstring, "Rollback failed with code %ld.\n", SQLCODE);
128
fprintf(stderr, "%s", errorstring);
129
printf("%s\n", errorstring);
140
/* exec sql begin declare section */
147
#line 49 "test_informix2.pgc"
150
#line 50 "test_informix2.pgc"
153
#line 51 "test_informix2.pgc"
156
#line 52 "test_informix2.pgc"
159
#line 53 "test_informix2.pgc"
161
/* exec sql end declare section */
162
#line 54 "test_informix2.pgc"
167
/* exec sql whenever sqlerror sqlprint ; */
168
#line 58 "test_informix2.pgc"
171
ECPGdebug(1, stderr);
173
strcpy(dbname, "regress1");
174
{ ECPGconnect(__LINE__, 1, dbname , NULL, NULL , NULL, 0);
175
#line 63 "test_informix2.pgc"
177
if (sqlca.sqlcode < 0) sqlprint();}
178
#line 63 "test_informix2.pgc"
180
sql_check("main", "connect", 0);
182
{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "set DateStyle to 'DMY'", ECPGt_EOIT, ECPGt_EORT);
183
#line 66 "test_informix2.pgc"
185
if (sqlca.sqlcode < 0) sqlprint();}
186
#line 66 "test_informix2.pgc"
189
{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "create table history ( customerid integer , timestamp timestamp without time zone , action_taken char ( 5 ) , narrative varchar ( 100 ) )", ECPGt_EOIT, ECPGt_EORT);
190
#line 68 "test_informix2.pgc"
192
if (sqlca.sqlcode < 0) sqlprint();}
193
#line 68 "test_informix2.pgc"
195
sql_check("main", "create", 0);
197
{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into history ( customerid , timestamp , action_taken , narrative ) values ( 1 , '2003-05-07 13:28:34 CEST' , 'test' , 'test' )", ECPGt_EOIT, ECPGt_EORT);
198
#line 73 "test_informix2.pgc"
200
if (sqlca.sqlcode < 0) sqlprint();}
201
#line 73 "test_informix2.pgc"
203
sql_check("main", "insert", 0);
205
{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "select max ( timestamp ) from history", ECPGt_EOIT,
206
ECPGt_timestamp,&(maxd),(long)1,(long)1,sizeof(timestamp),
207
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
208
#line 78 "test_informix2.pgc"
210
if (sqlca.sqlcode < 0) sqlprint();}
211
#line 78 "test_informix2.pgc"
213
sql_check("main", "select max", 100);
215
{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "select customerid , timestamp from history where timestamp = $1 limit 1",
216
ECPGt_timestamp,&(maxd),(long)1,(long)1,sizeof(timestamp),
217
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
218
ECPGt_int,&(c),(long)1,(long)1,sizeof(int),
219
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
220
ECPGt_timestamp,&(d),(long)1,(long)1,sizeof(timestamp),
221
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
222
#line 85 "test_informix2.pgc"
224
if (sqlca.sqlcode < 0) sqlprint();}
225
#line 85 "test_informix2.pgc"
227
sql_check("main", "select", 0);
229
printf("Read in customer %d\n", c);
231
intvl = PGTYPESinterval_from_asc("1 day 2 hours 24 minutes 65 seconds", NULL);
232
PGTYPEStimestamp_add_interval(&d, intvl, &e);
236
{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into history ( customerid , timestamp , action_taken , narrative ) values ( $1 , $2 , 'test' , 'test' )",
237
ECPGt_int,&(c),(long)1,(long)1,sizeof(int),
238
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
239
ECPGt_timestamp,&(e),(long)1,(long)1,sizeof(timestamp),
240
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
241
#line 97 "test_informix2.pgc"
243
if (sqlca.sqlcode < 0) sqlprint();}
244
#line 97 "test_informix2.pgc"
246
sql_check("main", "update", 0);
248
{ ECPGtrans(__LINE__, NULL, "commit");
249
#line 100 "test_informix2.pgc"
251
if (sqlca.sqlcode < 0) sqlprint();}
252
#line 100 "test_informix2.pgc"
255
{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "drop table history", ECPGt_EOIT, ECPGt_EORT);
256
#line 102 "test_informix2.pgc"
258
if (sqlca.sqlcode < 0) sqlprint();}
259
#line 102 "test_informix2.pgc"
261
sql_check("main", "drop", 0);
263
{ ECPGtrans(__LINE__, NULL, "commit");
264
#line 105 "test_informix2.pgc"
266
if (sqlca.sqlcode < 0) sqlprint();}
267
#line 105 "test_informix2.pgc"
270
{ ECPGdisconnect(__LINE__, "CURRENT");
271
#line 107 "test_informix2.pgc"
273
if (sqlca.sqlcode < 0) sqlprint();}
274
#line 107 "test_informix2.pgc"
276
sql_check("main", "disconnect", 0);
283
Table "public.history"
284
Column | Type | Modifiers
285
--------------+-----------------------------+-----------
286
customerid | integer | not null
287
timestamp | timestamp without time zone | not null
288
action_taken | character(5) | not null
289
narrative | character varying(100) |