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