| 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 "quote.pgc" |
| 10 |
#include <stdio.h> |
| 11 |
#include <stdlib.h> |
| 12 |
#include <string.h> |
| 13 |
|
| 14 |
|
| 15 |
#line 1 "regression.h" |
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
#line 5 "quote.pgc" |
| 23 |
|
| 24 |
|
| 25 |
int main() { |
| 26 |
/* exec sql begin declare section */ |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
#line 9 "quote.pgc" |
| 31 |
char var [ 25 ] ; |
| 32 |
|
| 33 |
#line 10 "quote.pgc" |
| 34 |
int i , loopcount ; |
| 35 |
/* exec sql end declare section */ |
| 36 |
#line 11 "quote.pgc" |
| 37 |
|
| 38 |
|
| 39 |
ECPGdebug(1, stderr); |
| 40 |
{ ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0); } |
| 41 |
#line 14 "quote.pgc" |
| 42 |
|
| 43 |
|
| 44 |
{ ECPGsetcommit(__LINE__, "on", NULL);} |
| 45 |
#line 16 "quote.pgc" |
| 46 |
|
| 47 |
/* exec sql whenever sql_warning sqlprint ; */ |
| 48 |
#line 17 "quote.pgc" |
| 49 |
|
| 50 |
/* exec sql whenever sqlerror stop ; */ |
| 51 |
#line 18 "quote.pgc" |
| 52 |
|
| 53 |
|
| 54 |
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table \"My_Table\" ( Item1 int , Item2 text )", ECPGt_EOIT, ECPGt_EORT); |
| 55 |
#line 20 "quote.pgc" |
| 56 |
|
| 57 |
if (sqlca.sqlwarn[0] == 'W') sqlprint(); |
| 58 |
#line 20 "quote.pgc" |
| 59 |
|
| 60 |
if (sqlca.sqlcode < 0) exit (1);} |
| 61 |
#line 20 "quote.pgc" |
| 62 |
|
| 63 |
|
| 64 |
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set standard_conforming_strings to off", ECPGt_EOIT, ECPGt_EORT); |
| 65 |
#line 22 "quote.pgc" |
| 66 |
|
| 67 |
if (sqlca.sqlwarn[0] == 'W') sqlprint(); |
| 68 |
#line 22 "quote.pgc" |
| 69 |
|
| 70 |
if (sqlca.sqlcode < 0) exit (1);} |
| 71 |
#line 22 "quote.pgc" |
| 72 |
|
| 73 |
|
| 74 |
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "show standard_conforming_strings", ECPGt_EOIT, |
| 75 |
ECPGt_char,(var),(long)25,(long)1,(25)*sizeof(char), |
| 76 |
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); |
| 77 |
#line 24 "quote.pgc" |
| 78 |
|
| 79 |
if (sqlca.sqlwarn[0] == 'W') sqlprint(); |
| 80 |
#line 24 "quote.pgc" |
| 81 |
|
| 82 |
if (sqlca.sqlcode < 0) exit (1);} |
| 83 |
#line 24 "quote.pgc" |
| 84 |
|
| 85 |
printf("Standard conforming strings: %s\n", var); |
| 86 |
|
| 87 |
/* this is a\\b actually */ |
| 88 |
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into \"My_Table\" values ( 1 , 'a\\\\\\\\b' )", ECPGt_EOIT, ECPGt_EORT); |
| 89 |
#line 28 "quote.pgc" |
| 90 |
|
| 91 |
if (sqlca.sqlwarn[0] == 'W') sqlprint(); |
| 92 |
#line 28 "quote.pgc" |
| 93 |
|
| 94 |
if (sqlca.sqlcode < 0) exit (1);} |
| 95 |
#line 28 "quote.pgc" |
| 96 |
|
| 97 |
/* this is a\\b */ |
| 98 |
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into \"My_Table\" values ( 1 , E'a\\\\\\\\b' )", ECPGt_EOIT, ECPGt_EORT); |
| 99 |
#line 30 "quote.pgc" |
| 100 |
|
| 101 |
if (sqlca.sqlwarn[0] == 'W') sqlprint(); |
| 102 |
#line 30 "quote.pgc" |
| 103 |
|
| 104 |
if (sqlca.sqlcode < 0) exit (1);} |
| 105 |
#line 30 "quote.pgc" |
| 106 |
|
| 107 |
|
| 108 |
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set standard_conforming_strings to on", ECPGt_EOIT, ECPGt_EORT); |
| 109 |
#line 32 "quote.pgc" |
| 110 |
|
| 111 |
if (sqlca.sqlwarn[0] == 'W') sqlprint(); |
| 112 |
#line 32 "quote.pgc" |
| 113 |
|
| 114 |
if (sqlca.sqlcode < 0) exit (1);} |
| 115 |
#line 32 "quote.pgc" |
| 116 |
|
| 117 |
|
| 118 |
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "show standard_conforming_strings", ECPGt_EOIT, |
| 119 |
ECPGt_char,(var),(long)25,(long)1,(25)*sizeof(char), |
| 120 |
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); |
| 121 |
#line 34 "quote.pgc" |
| 122 |
|
| 123 |
if (sqlca.sqlwarn[0] == 'W') sqlprint(); |
| 124 |
#line 34 "quote.pgc" |
| 125 |
|
| 126 |
if (sqlca.sqlcode < 0) exit (1);} |
| 127 |
#line 34 "quote.pgc" |
| 128 |
|
| 129 |
printf("Standard conforming strings: %s\n", var); |
| 130 |
|
| 131 |
/* this is a\\\\b actually */ |
| 132 |
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into \"My_Table\" values ( 2 , 'a\\\\\\\\b' )", ECPGt_EOIT, ECPGt_EORT); |
| 133 |
#line 38 "quote.pgc" |
| 134 |
|
| 135 |
if (sqlca.sqlwarn[0] == 'W') sqlprint(); |
| 136 |
#line 38 "quote.pgc" |
| 137 |
|
| 138 |
if (sqlca.sqlcode < 0) exit (1);} |
| 139 |
#line 38 "quote.pgc" |
| 140 |
|
| 141 |
/* this is a\\b */ |
| 142 |
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into \"My_Table\" values ( 2 , E'a\\\\\\\\b' )", ECPGt_EOIT, ECPGt_EORT); |
| 143 |
#line 40 "quote.pgc" |
| 144 |
|
| 145 |
if (sqlca.sqlwarn[0] == 'W') sqlprint(); |
| 146 |
#line 40 "quote.pgc" |
| 147 |
|
| 148 |
if (sqlca.sqlcode < 0) exit (1);} |
| 149 |
#line 40 "quote.pgc" |
| 150 |
|
| 151 |
|
| 152 |
{ ECPGtrans(__LINE__, NULL, "begin"); |
| 153 |
#line 42 "quote.pgc" |
| 154 |
|
| 155 |
if (sqlca.sqlwarn[0] == 'W') sqlprint(); |
| 156 |
#line 42 "quote.pgc" |
| 157 |
|
| 158 |
if (sqlca.sqlcode < 0) exit (1);} |
| 159 |
#line 42 "quote.pgc" |
| 160 |
|
| 161 |
/* declare C cursor for select * from \"My_Table\" */ |
| 162 |
#line 43 "quote.pgc" |
| 163 |
|
| 164 |
|
| 165 |
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare C cursor for select * from \"My_Table\"", ECPGt_EOIT, ECPGt_EORT); |
| 166 |
#line 45 "quote.pgc" |
| 167 |
|
| 168 |
if (sqlca.sqlwarn[0] == 'W') sqlprint(); |
| 169 |
#line 45 "quote.pgc" |
| 170 |
|
| 171 |
if (sqlca.sqlcode < 0) exit (1);} |
| 172 |
#line 45 "quote.pgc" |
| 173 |
|
| 174 |
|
| 175 |
/* exec sql whenever not found break ; */ |
| 176 |
#line 47 "quote.pgc" |
| 177 |
|
| 178 |
|
| 179 |
for (loopcount = 0; loopcount < 100; loopcount++) |
| 180 |
{ |
| 181 |
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch C", ECPGt_EOIT, |
| 182 |
ECPGt_int,&(i),(long)1,(long)1,sizeof(int), |
| 183 |
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, |
| 184 |
ECPGt_char,(var),(long)25,(long)1,(25)*sizeof(char), |
| 185 |
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT); |
| 186 |
#line 51 "quote.pgc" |
| 187 |
|
| 188 |
if (sqlca.sqlcode == ECPG_NOT_FOUND) break; |
| 189 |
#line 51 "quote.pgc" |
| 190 |
|
| 191 |
if (sqlca.sqlwarn[0] == 'W') sqlprint(); |
| 192 |
#line 51 "quote.pgc" |
| 193 |
|
| 194 |
if (sqlca.sqlcode < 0) exit (1);} |
| 195 |
#line 51 "quote.pgc" |
| 196 |
|
| 197 |
printf("value: %d %s\n", i, var); |
| 198 |
} |
| 199 |
|
| 200 |
{ ECPGtrans(__LINE__, NULL, "rollback"); |
| 201 |
#line 55 "quote.pgc" |
| 202 |
|
| 203 |
if (sqlca.sqlwarn[0] == 'W') sqlprint(); |
| 204 |
#line 55 "quote.pgc" |
| 205 |
|
| 206 |
if (sqlca.sqlcode < 0) exit (1);} |
| 207 |
#line 55 "quote.pgc" |
| 208 |
|
| 209 |
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table \"My_Table\"", ECPGt_EOIT, ECPGt_EORT); |
| 210 |
#line 56 "quote.pgc" |
| 211 |
|
| 212 |
if (sqlca.sqlwarn[0] == 'W') sqlprint(); |
| 213 |
#line 56 "quote.pgc" |
| 214 |
|
| 215 |
if (sqlca.sqlcode < 0) exit (1);} |
| 216 |
#line 56 "quote.pgc" |
| 217 |
|
| 218 |
|
| 219 |
{ ECPGdisconnect(__LINE__, "ALL"); |
| 220 |
#line 58 "quote.pgc" |
| 221 |
|
| 222 |
if (sqlca.sqlwarn[0] == 'W') sqlprint(); |
| 223 |
#line 58 "quote.pgc" |
| 224 |
|
| 225 |
if (sqlca.sqlcode < 0) exit (1);} |
| 226 |
#line 58 "quote.pgc" |
| 227 |
|
| 228 |
|
| 229 |
return 0; |
| 230 |
} |