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 "indicators.pgc"
10 #include <stdio.h>
11
12
13 #line 1 "sqlca.h"
14 #ifndef POSTGRES_SQLCA_H
15 #define POSTGRES_SQLCA_H
16
17 #ifndef PGDLLIMPORT
18 #if defined(WIN32) || defined(__CYGWIN__)
19 #define PGDLLIMPORT __declspec (dllimport)
20 #else
21 #define PGDLLIMPORT
22 #endif /* __CYGWIN__ */
23 #endif /* PGDLLIMPORT */
24
25 #define SQLERRMC_LEN 150
26
27 #ifdef __cplusplus
28 extern "C"
29 {
30 #endif
31
32 struct sqlca_t
33 {
34 char sqlcaid[8];
35 long sqlabc;
36 long sqlcode;
37 struct
38 {
39 int sqlerrml;
40 char sqlerrmc[SQLERRMC_LEN];
41 } sqlerrm;
42 char sqlerrp[8];
43 long sqlerrd[6];
44 /* Element 0: empty */
45 /* 1: OID of processed tuple if applicable */
46 /* 2: number of rows processed */
47 /* after an INSERT, UPDATE or */
48 /* DELETE statement */
49 /* 3: empty */
50 /* 4: empty */
51 /* 5: empty */
52 char sqlwarn[8];
53 /* Element 0: set to 'W' if at least one other is 'W' */
54 /* 1: if 'W' at least one character string */
55 /* value was truncated when it was */
56 /* stored into a host variable. */
57
58 /*
59 * 2: if 'W' a (hopefully) non-fatal notice occurred
60 */ /* 3: empty */
61 /* 4: empty */
62 /* 5: empty */
63 /* 6: empty */
64 /* 7: empty */
65
66 char sqlstate[5];
67 };
68
69 struct sqlca_t *ECPGget_sqlca(void);
70
71 #ifndef POSTGRES_ECPG_INTERNAL
72 #define sqlca (*ECPGget_sqlca())
73 #endif
74
75 #ifdef __cplusplus
76 }
77 #endif
78
79 #endif
80
81 #line 3 "indicators.pgc"
82
83
84 #line 1 "regression.h"
85
86
87
88
89
90
91 #line 4 "indicators.pgc"
92
93
main()94 int main()
95 {
96 /* exec sql begin declare section */
97
98
99
100 #line 9 "indicators.pgc"
101 int intvar = 5 ;
102
103 #line 10 "indicators.pgc"
104 int nullind = - 1 ;
105 /* exec sql end declare section */
106 #line 11 "indicators.pgc"
107
108
109 ECPGdebug(1,stderr);
110
111 { ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0); }
112 #line 15 "indicators.pgc"
113
114 { ECPGsetcommit(__LINE__, "off", NULL);}
115 #line 16 "indicators.pgc"
116
117
118 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table indicator_test ( \"id\" int primary key , \"str\" text not null , val int null )", ECPGt_EOIT, ECPGt_EORT);}
119 #line 21 "indicators.pgc"
120
121 { ECPGtrans(__LINE__, NULL, "commit work");}
122 #line 22 "indicators.pgc"
123
124
125 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into indicator_test ( id , str , val ) values ( 1 , 'Hello' , 0 )", ECPGt_EOIT, ECPGt_EORT);}
126 #line 24 "indicators.pgc"
127
128
129 /* use indicator in insert */
130 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into indicator_test ( id , str , val ) values ( 2 , 'Hi there' , $1 )",
131 ECPGt_int,&(intvar),(long)1,(long)1,sizeof(int),
132 ECPGt_int,&(nullind),(long)1,(long)1,sizeof(int), ECPGt_EOIT, ECPGt_EORT);}
133 #line 27 "indicators.pgc"
134
135 nullind = 0;
136 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into indicator_test ( id , str , val ) values ( 3 , 'Good evening' , $1 )",
137 ECPGt_int,&(intvar),(long)1,(long)1,sizeof(int),
138 ECPGt_int,&(nullind),(long)1,(long)1,sizeof(int), ECPGt_EOIT, ECPGt_EORT);}
139 #line 29 "indicators.pgc"
140
141 { ECPGtrans(__LINE__, NULL, "commit work");}
142 #line 30 "indicators.pgc"
143
144
145 /* use indicators to get information about selects */
146 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select val from indicator_test where id = 1", ECPGt_EOIT,
147 ECPGt_int,&(intvar),(long)1,(long)1,sizeof(int),
148 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
149 #line 33 "indicators.pgc"
150
151 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select val from indicator_test where id = 2", ECPGt_EOIT,
152 ECPGt_int,&(intvar),(long)1,(long)1,sizeof(int),
153 ECPGt_int,&(nullind),(long)1,(long)1,sizeof(int), ECPGt_EORT);}
154 #line 34 "indicators.pgc"
155
156 printf("intvar: %d, nullind: %d\n", intvar, nullind);
157 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select val from indicator_test where id = 3", ECPGt_EOIT,
158 ECPGt_int,&(intvar),(long)1,(long)1,sizeof(int),
159 ECPGt_int,&(nullind),(long)1,(long)1,sizeof(int), ECPGt_EORT);}
160 #line 36 "indicators.pgc"
161
162 printf("intvar: %d, nullind: %d\n", intvar, nullind);
163
164 /* use indicators for update */
165 intvar = 5; nullind = -1;
166 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update indicator_test set val = $1 where id = 1",
167 ECPGt_int,&(intvar),(long)1,(long)1,sizeof(int),
168 ECPGt_int,&(nullind),(long)1,(long)1,sizeof(int), ECPGt_EOIT, ECPGt_EORT);}
169 #line 41 "indicators.pgc"
170
171 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select val from indicator_test where id = 1", ECPGt_EOIT,
172 ECPGt_int,&(intvar),(long)1,(long)1,sizeof(int),
173 ECPGt_int,&(nullind),(long)1,(long)1,sizeof(int), ECPGt_EORT);}
174 #line 42 "indicators.pgc"
175
176 printf("intvar: %d, nullind: %d\n", intvar, nullind);
177
178 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table indicator_test", ECPGt_EOIT, ECPGt_EORT);}
179 #line 45 "indicators.pgc"
180
181 { ECPGtrans(__LINE__, NULL, "commit work");}
182 #line 46 "indicators.pgc"
183
184
185 { ECPGdisconnect(__LINE__, "CURRENT");}
186 #line 48 "indicators.pgc"
187
188 return 0;
189 }
190