PostgreSQL Source Code  git master
preproc-define.c
Go to the documentation of this file.
1 /* Processed by ecpg (regression mode) */
2 /* These include files are added by the preprocessor */
3 #include <ecpglib.h>
4 #include <ecpgerrno.h>
5 #include <sqlca.h>
6 /* End of automatic include section */
7 #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
8 
9 #line 1 "define.pgc"
10 #include <stdlib.h>
11 #include <string.h>
12 #include <stdio.h>
13 
14 
15 #line 1 "regression.h"
16 
17 
18 
19 
20 
21 
22 #line 5 "define.pgc"
23 
24 
25 /* exec sql whenever sqlerror sqlprint ; */
26 #line 7 "define.pgc"
27 
28 
29 
30 
31 
32 /* exec sql type intarray is int [ 6 ] */
33 #line 12 "define.pgc"
34 
35 typedef int intarray[ 6];
36 
37 int
38 main(void)
39 {
40 /* exec sql begin declare section */
41 
42 
43  typedef char string [ 8 ];
44 
45 #line 21 "define.pgc"
46 
47 
48 
49 
50 
51 
52 
53 
54 
55 
56 
57 
58 
59 
60 
61 
62 
63 
64 
65 
66 
67 #line 22 "define.pgc"
68  intarray amount ;
69 
70 #line 23 "define.pgc"
71  char name [ 6 ] [ 8 ] ;
72 
73 #line 36 "define.pgc"
74  char letter [ 6 ] [ 1 ] ;
75 
76 #if 0
77 
78 #line 38 "define.pgc"
79  int not_used ;
80 
81 #endif
82 /* exec sql end declare section */
83 #line 45 "define.pgc"
84 
85  int i,j;
86 
87  ECPGdebug(1, stderr);
88 
89  { ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0);
90 #line 50 "define.pgc"
91 
92 if (sqlca.sqlcode < 0) sqlprint();}
93 #line 50 "define.pgc"
94 
95 
96  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table test ( name char ( 8 ) , amount int , letter char ( 1 ) )", ECPGt_EOIT, ECPGt_EORT);
97 #line 52 "define.pgc"
98 
99 if (sqlca.sqlcode < 0) sqlprint();}
100 #line 52 "define.pgc"
101 
102  { ECPGtrans(__LINE__, NULL, "commit");
103 #line 53 "define.pgc"
104 
105 if (sqlca.sqlcode < 0) sqlprint();}
106 #line 53 "define.pgc"
107 
108 
109  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into Test ( name , amount , letter ) values ( 'false' , 1 , 'f' )", ECPGt_EOIT, ECPGt_EORT);
110 #line 55 "define.pgc"
111 
112 if (sqlca.sqlcode < 0) sqlprint();}
113 #line 55 "define.pgc"
114 
115  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test ( name , amount , letter ) values ( 'true' , 2 , 't' )", ECPGt_EOIT, ECPGt_EORT);
116 #line 56 "define.pgc"
117 
118 if (sqlca.sqlcode < 0) sqlprint();}
119 #line 56 "define.pgc"
120 
121  { ECPGtrans(__LINE__, NULL, "commit");
122 #line 57 "define.pgc"
123 
124 if (sqlca.sqlcode < 0) sqlprint();}
125 #line 57 "define.pgc"
126 
127 
128  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select * from test", ECPGt_EOIT,
129  ECPGt_char,(name),(long)8,(long)6,(8)*sizeof(char),
130  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
131  ECPGt_int,(amount),(long)1,(long)6,sizeof(int),
132  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
133  ECPGt_char,(letter),(long)1,(long)6,(1)*sizeof(char),
134  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
135 #line 59 "define.pgc"
136 
137 if (sqlca.sqlcode < 0) sqlprint();}
138 #line 59 "define.pgc"
139 
140 
141  for (i=0, j=sqlca.sqlerrd[2]; i<j; i++)
142  {
143  /* exec sql begin declare section */
144 
145 
146 
147 
148 #line 64 "define.pgc"
149  string n ;
150 
151 #line 65 "define.pgc"
152  char l = letter [ i ] [ 0 ] ;
153 
154 #line 66 "define.pgc"
155  int a = amount [ i ] ;
156 /* exec sql end declare section */
157 #line 67 "define.pgc"
158 
159 
160  strncpy(n, name[i], 8);
161  printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n", i, n, i, a, i, l);
162  }
163 
164  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table test", ECPGt_EOIT, ECPGt_EORT);
165 #line 73 "define.pgc"
166 
167 if (sqlca.sqlcode < 0) sqlprint();}
168 #line 73 "define.pgc"
169 
170  { ECPGtrans(__LINE__, NULL, "commit");
171 #line 74 "define.pgc"
172 
173 if (sqlca.sqlcode < 0) sqlprint();}
174 #line 74 "define.pgc"
175 
176  { ECPGdisconnect(__LINE__, "CURRENT");
177 #line 75 "define.pgc"
178 
179 if (sqlca.sqlcode < 0) sqlprint();}
180 #line 75 "define.pgc"
181 
182 
183  return 0;
184 }
bool ECPGdisconnect(int lineno, const char *connection_name)
Definition: connect.c:667
bool ECPGconnect(int lineno, int c, const char *name, const char *user, const char *passwd, const char *connection_name, int autocommit)
Definition: connect.c:273
@ ECPGst_normal
Definition: ecpgtype.h:97
@ ECPGt_EOIT
Definition: ecpgtype.h:62
@ ECPGt_int
Definition: ecpgtype.h:44
@ ECPGt_NO_INDICATOR
Definition: ecpgtype.h:64
@ ECPGt_EORT
Definition: ecpgtype.h:63
@ ECPGt_char
Definition: ecpgtype.h:43
const char * name
Definition: encode.c:561
void sqlprint(void)
Definition: error.c:334
bool ECPGdo(const int lineno, const int compat, const int force_indicator, const char *connection_name, const bool questionmarks, const int st, const char *query,...)
Definition: execute.c:2286
bool ECPGtrans(int lineno, const char *connection_name, const char *transaction)
Definition: misc.c:197
int a
Definition: isn.c:69
int j
Definition: isn.c:74
int i
Definition: isn.c:73
#define printf(...)
Definition: port.h:231
int main(void)
int intarray[6]
#define ECPGdebug(X, Y)
Definition: preproc-define.c:7
#define sqlca
Definition: sqlca.h:59