Header And Logo

PostgreSQL
| The world's most advanced open source database.

sql-quote.c

Go to the documentation of this file.
00001 /* Processed by ecpg (regression mode) */
00002 /* These include files are added by the preprocessor */
00003 #include <ecpglib.h>
00004 #include <ecpgerrno.h>
00005 #include <sqlca.h>
00006 /* End of automatic include section */
00007 #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
00008 
00009 #line 1 "quote.pgc"
00010 #include <stdio.h>
00011 #include <stdlib.h>
00012 #include <string.h>
00013 
00014 
00015 #line 1 "regression.h"
00016 
00017 
00018 
00019 
00020 
00021 
00022 #line 5 "quote.pgc"
00023 
00024 
00025 int main() {
00026   /* exec sql begin declare section */
00027      
00028      
00029   
00030 #line 9 "quote.pgc"
00031  char var [ 25 ] ;
00032  
00033 #line 10 "quote.pgc"
00034  int i ;
00035 /* exec sql end declare section */
00036 #line 11 "quote.pgc"
00037 
00038 
00039   ECPGdebug(1, stderr);
00040   { ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); }
00041 #line 14 "quote.pgc"
00042 
00043 
00044   { ECPGsetcommit(__LINE__, "on", NULL);}
00045 #line 16 "quote.pgc"
00046 
00047   /* exec sql whenever sql_warning  sqlprint ; */
00048 #line 17 "quote.pgc"
00049 
00050   /* exec sql whenever sqlerror  sqlprint ; */
00051 #line 18 "quote.pgc"
00052 
00053 
00054   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table \"My_Table\" ( Item1 int , Item2 text )", ECPGt_EOIT, ECPGt_EORT);
00055 #line 20 "quote.pgc"
00056 
00057 if (sqlca.sqlwarn[0] == 'W') sqlprint();
00058 #line 20 "quote.pgc"
00059 
00060 if (sqlca.sqlcode < 0) sqlprint();}
00061 #line 20 "quote.pgc"
00062 
00063 
00064   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set standard_conforming_strings to off", ECPGt_EOIT, ECPGt_EORT);
00065 #line 22 "quote.pgc"
00066 
00067 if (sqlca.sqlwarn[0] == 'W') sqlprint();
00068 #line 22 "quote.pgc"
00069 
00070 if (sqlca.sqlcode < 0) sqlprint();}
00071 #line 22 "quote.pgc"
00072 
00073 
00074   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "show standard_conforming_strings", ECPGt_EOIT, 
00075     ECPGt_char,(var),(long)25,(long)1,(25)*sizeof(char), 
00076     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
00077 #line 24 "quote.pgc"
00078 
00079 if (sqlca.sqlwarn[0] == 'W') sqlprint();
00080 #line 24 "quote.pgc"
00081 
00082 if (sqlca.sqlcode < 0) sqlprint();}
00083 #line 24 "quote.pgc"
00084 
00085   printf("Standard conforming strings: %s\n", var);
00086 
00087   /* this is a\\b actually */
00088   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into \"My_Table\" values ( 1 , 'a\\\\\\\\b' )", ECPGt_EOIT, ECPGt_EORT);
00089 #line 28 "quote.pgc"
00090 
00091 if (sqlca.sqlwarn[0] == 'W') sqlprint();
00092 #line 28 "quote.pgc"
00093 
00094 if (sqlca.sqlcode < 0) sqlprint();}
00095 #line 28 "quote.pgc"
00096 
00097   /* this is a\\b */
00098   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into \"My_Table\" values ( 1 , E'a\\\\\\\\b' )", ECPGt_EOIT, ECPGt_EORT);
00099 #line 30 "quote.pgc"
00100 
00101 if (sqlca.sqlwarn[0] == 'W') sqlprint();
00102 #line 30 "quote.pgc"
00103 
00104 if (sqlca.sqlcode < 0) sqlprint();}
00105 #line 30 "quote.pgc"
00106 
00107 
00108   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set standard_conforming_strings to on", ECPGt_EOIT, ECPGt_EORT);
00109 #line 32 "quote.pgc"
00110 
00111 if (sqlca.sqlwarn[0] == 'W') sqlprint();
00112 #line 32 "quote.pgc"
00113 
00114 if (sqlca.sqlcode < 0) sqlprint();}
00115 #line 32 "quote.pgc"
00116 
00117 
00118   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "show standard_conforming_strings", ECPGt_EOIT, 
00119     ECPGt_char,(var),(long)25,(long)1,(25)*sizeof(char), 
00120     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
00121 #line 34 "quote.pgc"
00122 
00123 if (sqlca.sqlwarn[0] == 'W') sqlprint();
00124 #line 34 "quote.pgc"
00125 
00126 if (sqlca.sqlcode < 0) sqlprint();}
00127 #line 34 "quote.pgc"
00128 
00129   printf("Standard conforming strings: %s\n", var);
00130 
00131   /* this is a\\\\b actually */
00132   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into \"My_Table\" values ( 2 , 'a\\\\\\\\b' )", ECPGt_EOIT, ECPGt_EORT);
00133 #line 38 "quote.pgc"
00134 
00135 if (sqlca.sqlwarn[0] == 'W') sqlprint();
00136 #line 38 "quote.pgc"
00137 
00138 if (sqlca.sqlcode < 0) sqlprint();}
00139 #line 38 "quote.pgc"
00140 
00141   /* this is a\\b */
00142   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into \"My_Table\" values ( 2 , E'a\\\\\\\\b' )", ECPGt_EOIT, ECPGt_EORT);
00143 #line 40 "quote.pgc"
00144 
00145 if (sqlca.sqlwarn[0] == 'W') sqlprint();
00146 #line 40 "quote.pgc"
00147 
00148 if (sqlca.sqlcode < 0) sqlprint();}
00149 #line 40 "quote.pgc"
00150 
00151 
00152   { ECPGtrans(__LINE__, NULL, "begin");
00153 #line 42 "quote.pgc"
00154 
00155 if (sqlca.sqlwarn[0] == 'W') sqlprint();
00156 #line 42 "quote.pgc"
00157 
00158 if (sqlca.sqlcode < 0) sqlprint();}
00159 #line 42 "quote.pgc"
00160 
00161   /* declare C cursor for select * from \"My_Table\" */
00162 #line 43 "quote.pgc"
00163 
00164 
00165   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare C cursor for select * from \"My_Table\"", ECPGt_EOIT, ECPGt_EORT);
00166 #line 45 "quote.pgc"
00167 
00168 if (sqlca.sqlwarn[0] == 'W') sqlprint();
00169 #line 45 "quote.pgc"
00170 
00171 if (sqlca.sqlcode < 0) sqlprint();}
00172 #line 45 "quote.pgc"
00173 
00174 
00175   /* exec sql whenever not found  break ; */
00176 #line 47 "quote.pgc"
00177 
00178 
00179   while (true)
00180   {
00181     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch C", ECPGt_EOIT, 
00182     ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
00183     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
00184     ECPGt_char,(var),(long)25,(long)1,(25)*sizeof(char), 
00185     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
00186 #line 51 "quote.pgc"
00187 
00188 if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
00189 #line 51 "quote.pgc"
00190 
00191 if (sqlca.sqlwarn[0] == 'W') sqlprint();
00192 #line 51 "quote.pgc"
00193 
00194 if (sqlca.sqlcode < 0) sqlprint();}
00195 #line 51 "quote.pgc"
00196 
00197     printf("value: %d %s\n", i, var);
00198   }
00199 
00200   { ECPGtrans(__LINE__, NULL, "rollback");
00201 #line 55 "quote.pgc"
00202 
00203 if (sqlca.sqlwarn[0] == 'W') sqlprint();
00204 #line 55 "quote.pgc"
00205 
00206 if (sqlca.sqlcode < 0) sqlprint();}
00207 #line 55 "quote.pgc"
00208 
00209   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table \"My_Table\"", ECPGt_EOIT, ECPGt_EORT);
00210 #line 56 "quote.pgc"
00211 
00212 if (sqlca.sqlwarn[0] == 'W') sqlprint();
00213 #line 56 "quote.pgc"
00214 
00215 if (sqlca.sqlcode < 0) sqlprint();}
00216 #line 56 "quote.pgc"
00217 
00218 
00219   { ECPGdisconnect(__LINE__, "ALL");
00220 #line 58 "quote.pgc"
00221 
00222 if (sqlca.sqlwarn[0] == 'W') sqlprint();
00223 #line 58 "quote.pgc"
00224 
00225 if (sqlca.sqlcode < 0) sqlprint();}
00226 #line 58 "quote.pgc"
00227 
00228 
00229   return 0;
00230 }