1 /* Processed by ecpg (regression mode) */
2 /* These include files are added by the preprocessor */
6 /* End of automatic include section */
7 #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
14 /* exec sql whenever sqlerror sqlprint ; */
20 #ifndef POSTGRES_SQLCA_H
21 #define POSTGRES_SQLCA_H
24 #if defined(WIN32) || defined(__CYGWIN__)
25 #define PGDLLIMPORT __declspec (dllimport)
28 #endif /* __CYGWIN__ */
29 #endif /* PGDLLIMPORT */
31 #define SQLERRMC_LEN 150
46 char sqlerrmc[SQLERRMC_LEN];
50 /* Element 0: empty */
51 /* 1: OID of processed tuple if applicable */
52 /* 2: number of rows processed */
53 /* after an INSERT, UPDATE or */
54 /* DELETE statement */
59 /* Element 0: set to 'W' if at least one other is 'W' */
60 /* 1: if 'W' at least one character string */
61 /* value was truncated when it was */
62 /* stored into a host variable. */
65 * 2: if 'W' a (hopefully) non-fatal notice occurred
75 struct sqlca_t *ECPGget_sqlca(void);
77 #ifndef POSTGRES_ECPG_INTERNAL
78 #define sqlca (*ECPGget_sqlca())
90 #line 1 "regression.h"
103 /* exec sql begin declare section */
118 int a [ 10 ] = { 9 , 8 , 7 , 6 , 5 , 4 , 3 , 2 , 1 , 0 } ;
121 char text [ 25 ] = "klmnopqrst" ;
124 char * t = ( char * ) malloc ( 11 ) ;
128 /* exec sql end declare section */
132 strcpy(t, "0123456789");
133 setlocale(LC_ALL, "C");
135 ECPGdebug(1, stderr);
137 { ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0);
140 if (sqlca.sqlcode < 0) sqlprint();}
144 { ECPGsetcommit(__LINE__, "on", NULL);
147 if (sqlca.sqlcode < 0) sqlprint();}
151 { ECPGtrans(__LINE__, NULL, "begin work");
154 if (sqlca.sqlcode < 0) sqlprint();}
158 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table test ( f float , i int , a int [ 10 ] , text char ( 10 ) )", ECPGt_EOIT, ECPGt_EORT);
161 if (sqlca.sqlcode < 0) sqlprint();}
165 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test ( f , i , a , text ) values ( 404.90 , 3 , '{0,1,2,3,4,5,6,7,8,9}' , 'abcdefghij' )", ECPGt_EOIT, ECPGt_EORT);
168 if (sqlca.sqlcode < 0) sqlprint();}
172 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test ( f , i , a , text ) values ( 140787.0 , 2 , $1 , $2 )",
173 ECPGt_int,(a),(long)1,(long)10,sizeof(int),
174 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
175 ECPGt_char,(text),(long)25,(long)1,(25)*sizeof(char),
176 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
179 if (sqlca.sqlcode < 0) sqlprint();}
183 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test ( f , i , a , text ) values ( 14.07 , $1 , $2 , $3 )",
184 ECPGt_int,&(did),(long)1,(long)0,sizeof(int),
185 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
186 ECPGt_int,(a),(long)1,(long)10,sizeof(int),
187 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
188 ECPGt_char,&(t),(long)0,(long)1,(1)*sizeof(char),
189 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
192 if (sqlca.sqlcode < 0) sqlprint();}
196 { ECPGtrans(__LINE__, NULL, "commit");
199 if (sqlca.sqlcode < 0) sqlprint();}
203 { ECPGtrans(__LINE__, NULL, "begin work");
206 if (sqlca.sqlcode < 0) sqlprint();}
210 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select f , text from test where i = 1", ECPGt_EOIT,
211 ECPGt_double,&(f),(long)1,(long)1,sizeof(double),
212 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
213 ECPGt_char,(text),(long)25,(long)1,(25)*sizeof(char),
214 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
217 if (sqlca.sqlcode < 0) sqlprint();}
221 printf("Found f=%f text=%10.10s\n", f, text);
224 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select a , text from test where f = $1 ",
225 ECPGt_double,&(f),(long)1,(long)1,sizeof(double),
226 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
227 ECPGt_int,(a),(long)1,(long)10,sizeof(int),
228 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
229 ECPGt_char,&(t),(long)0,(long)1,(1)*sizeof(char),
230 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
233 if (sqlca.sqlcode < 0) sqlprint();}
237 for (i = 0; i < 10; i++)
238 printf("Found a[%d] = %d\n", i, a[i]);
240 printf("Found text=%10.10s\n", t);
242 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select a from test where f = $1 ",
243 ECPGt_double,&(f),(long)1,(long)1,sizeof(double),
244 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
245 ECPGt_char,(text),(long)25,(long)1,(25)*sizeof(char),
246 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
249 if (sqlca.sqlcode < 0) sqlprint();}
253 printf("Found text=%s\n", text);
255 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table test", ECPGt_EOIT, ECPGt_EORT);
258 if (sqlca.sqlcode < 0) sqlprint();}
262 { ECPGtrans(__LINE__, NULL, "commit");
265 if (sqlca.sqlcode < 0) sqlprint();}
269 { ECPGdisconnect(__LINE__, "CURRENT");
272 if (sqlca.sqlcode < 0) sqlprint();}