Header And Logo

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

sql-fetch.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 "fetch.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 "fetch.pgc"
00023 
00024 
00025 int main() {
00026   /* exec sql begin declare section */
00027      
00028       
00029   
00030 #line 9 "fetch.pgc"
00031  char str [ 25 ] ;
00032  
00033 #line 10 "fetch.pgc"
00034  int i , count = 1 ;
00035 /* exec sql end declare section */
00036 #line 11 "fetch.pgc"
00037 
00038 
00039   ECPGdebug(1, stderr);
00040   { ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); }
00041 #line 14 "fetch.pgc"
00042 
00043 
00044   /* exec sql whenever sql_warning  sqlprint ; */
00045 #line 16 "fetch.pgc"
00046 
00047   /* exec sql whenever sqlerror  sqlprint ; */
00048 #line 17 "fetch.pgc"
00049 
00050 
00051   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table My_Table ( Item1 int , Item2 text )", ECPGt_EOIT, ECPGt_EORT);
00052 #line 19 "fetch.pgc"
00053 
00054 if (sqlca.sqlwarn[0] == 'W') sqlprint();
00055 #line 19 "fetch.pgc"
00056 
00057 if (sqlca.sqlcode < 0) sqlprint();}
00058 #line 19 "fetch.pgc"
00059 
00060 
00061   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into My_Table values ( 1 , 'text1' )", ECPGt_EOIT, ECPGt_EORT);
00062 #line 21 "fetch.pgc"
00063 
00064 if (sqlca.sqlwarn[0] == 'W') sqlprint();
00065 #line 21 "fetch.pgc"
00066 
00067 if (sqlca.sqlcode < 0) sqlprint();}
00068 #line 21 "fetch.pgc"
00069 
00070   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into My_Table values ( 2 , 'text2' )", ECPGt_EOIT, ECPGt_EORT);
00071 #line 22 "fetch.pgc"
00072 
00073 if (sqlca.sqlwarn[0] == 'W') sqlprint();
00074 #line 22 "fetch.pgc"
00075 
00076 if (sqlca.sqlcode < 0) sqlprint();}
00077 #line 22 "fetch.pgc"
00078 
00079   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into My_Table values ( 3 , 'text3' )", ECPGt_EOIT, ECPGt_EORT);
00080 #line 23 "fetch.pgc"
00081 
00082 if (sqlca.sqlwarn[0] == 'W') sqlprint();
00083 #line 23 "fetch.pgc"
00084 
00085 if (sqlca.sqlcode < 0) sqlprint();}
00086 #line 23 "fetch.pgc"
00087 
00088   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into My_Table values ( 4 , 'text4' )", ECPGt_EOIT, ECPGt_EORT);
00089 #line 24 "fetch.pgc"
00090 
00091 if (sqlca.sqlwarn[0] == 'W') sqlprint();
00092 #line 24 "fetch.pgc"
00093 
00094 if (sqlca.sqlcode < 0) sqlprint();}
00095 #line 24 "fetch.pgc"
00096 
00097 
00098   /* declare C cursor for select * from My_Table */
00099 #line 26 "fetch.pgc"
00100 
00101 
00102   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare C cursor for select * from My_Table", ECPGt_EOIT, ECPGt_EORT);
00103 #line 28 "fetch.pgc"
00104 
00105 if (sqlca.sqlwarn[0] == 'W') sqlprint();
00106 #line 28 "fetch.pgc"
00107 
00108 if (sqlca.sqlcode < 0) sqlprint();}
00109 #line 28 "fetch.pgc"
00110 
00111 
00112   /* exec sql whenever not found  break ; */
00113 #line 30 "fetch.pgc"
00114 
00115   while (1) {
00116     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 1 in C", ECPGt_EOIT, 
00117     ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
00118     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
00119     ECPGt_char,(str),(long)25,(long)1,(25)*sizeof(char), 
00120     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
00121 #line 32 "fetch.pgc"
00122 
00123 if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
00124 #line 32 "fetch.pgc"
00125 
00126 if (sqlca.sqlwarn[0] == 'W') sqlprint();
00127 #line 32 "fetch.pgc"
00128 
00129 if (sqlca.sqlcode < 0) sqlprint();}
00130 #line 32 "fetch.pgc"
00131 
00132     printf("%d: %s\n", i, str);
00133   }
00134 
00135   /* exec sql whenever not found  continue ; */
00136 #line 36 "fetch.pgc"
00137 
00138   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "move backward 2 in C", ECPGt_EOIT, ECPGt_EORT);
00139 #line 37 "fetch.pgc"
00140 
00141 if (sqlca.sqlwarn[0] == 'W') sqlprint();
00142 #line 37 "fetch.pgc"
00143 
00144 if (sqlca.sqlcode < 0) sqlprint();}
00145 #line 37 "fetch.pgc"
00146 
00147 
00148   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch $0 in C", 
00149     ECPGt_int,&(count),(long)1,(long)1,sizeof(int), 
00150     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
00151     ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
00152     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
00153     ECPGt_char,(str),(long)25,(long)1,(25)*sizeof(char), 
00154     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
00155 #line 39 "fetch.pgc"
00156 
00157 if (sqlca.sqlwarn[0] == 'W') sqlprint();
00158 #line 39 "fetch.pgc"
00159 
00160 if (sqlca.sqlcode < 0) sqlprint();}
00161 #line 39 "fetch.pgc"
00162 
00163   printf("%d: %s\n", i, str);
00164 
00165   /* declare D cursor for select * from My_Table where Item1 = $1 */
00166 #line 42 "fetch.pgc"
00167 
00168 
00169   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare D cursor for select * from My_Table where Item1 = $1", 
00170     ECPGt_const,"1",(long)1,(long)1,strlen("1"), 
00171     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
00172 #line 44 "fetch.pgc"
00173 
00174 if (sqlca.sqlwarn[0] == 'W') sqlprint();
00175 #line 44 "fetch.pgc"
00176 
00177 if (sqlca.sqlcode < 0) sqlprint();}
00178 #line 44 "fetch.pgc"
00179 
00180 
00181   /* exec sql whenever not found  break ; */
00182 #line 46 "fetch.pgc"
00183 
00184   while (1) {
00185     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 1 in D", ECPGt_EOIT, 
00186     ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
00187     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
00188     ECPGt_char,(str),(long)25,(long)1,(25)*sizeof(char), 
00189     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
00190 #line 48 "fetch.pgc"
00191 
00192 if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
00193 #line 48 "fetch.pgc"
00194 
00195 if (sqlca.sqlwarn[0] == 'W') sqlprint();
00196 #line 48 "fetch.pgc"
00197 
00198 if (sqlca.sqlcode < 0) sqlprint();}
00199 #line 48 "fetch.pgc"
00200 
00201     printf("%d: %s\n", i, str);
00202   }
00203   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close D", ECPGt_EOIT, ECPGt_EORT);
00204 #line 51 "fetch.pgc"
00205 
00206 if (sqlca.sqlwarn[0] == 'W') sqlprint();
00207 #line 51 "fetch.pgc"
00208 
00209 if (sqlca.sqlcode < 0) sqlprint();}
00210 #line 51 "fetch.pgc"
00211 
00212 
00213   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table My_Table", ECPGt_EOIT, ECPGt_EORT);
00214 #line 53 "fetch.pgc"
00215 
00216 if (sqlca.sqlwarn[0] == 'W') sqlprint();
00217 #line 53 "fetch.pgc"
00218 
00219 if (sqlca.sqlcode < 0) sqlprint();}
00220 #line 53 "fetch.pgc"
00221 
00222 
00223   { ECPGdisconnect(__LINE__, "ALL");
00224 #line 55 "fetch.pgc"
00225 
00226 if (sqlca.sqlwarn[0] == 'W') sqlprint();
00227 #line 55 "fetch.pgc"
00228 
00229 if (sqlca.sqlcode < 0) sqlprint();}
00230 #line 55 "fetch.pgc"
00231 
00232 
00233   return 0;
00234 }