Header And Logo

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

sql-insupd.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 "insupd.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 "insupd.pgc"
00023 
00024 
00025 int main() {
00026   /* exec sql begin declare section */
00027         
00028   
00029 #line 9 "insupd.pgc"
00030  int i1 [ 3 ] , i2 [ 3 ] , i3 [ 3 ] , i4 ;
00031 /* exec sql end declare section */
00032 #line 10 "insupd.pgc"
00033 
00034 
00035   ECPGdebug(1, stderr);
00036   { ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); }
00037 #line 13 "insupd.pgc"
00038 
00039 
00040   /* exec sql whenever sql_warning  sqlprint ; */
00041 #line 15 "insupd.pgc"
00042 
00043   /* exec sql whenever sqlerror  sqlprint ; */
00044 #line 16 "insupd.pgc"
00045 
00046 
00047   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table insupd_test ( a int , b int )", ECPGt_EOIT, ECPGt_EORT);
00048 #line 18 "insupd.pgc"
00049 
00050 if (sqlca.sqlwarn[0] == 'W') sqlprint();
00051 #line 18 "insupd.pgc"
00052 
00053 if (sqlca.sqlcode < 0) sqlprint();}
00054 #line 18 "insupd.pgc"
00055 
00056 
00057   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into insupd_test ( a , b ) values ( 1 , 1 )", ECPGt_EOIT, ECPGt_EORT);
00058 #line 20 "insupd.pgc"
00059 
00060 if (sqlca.sqlwarn[0] == 'W') sqlprint();
00061 #line 20 "insupd.pgc"
00062 
00063 if (sqlca.sqlcode < 0) sqlprint();}
00064 #line 20 "insupd.pgc"
00065 
00066   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into insupd_test ( a , b ) values ( 2 , 2 )", ECPGt_EOIT, ECPGt_EORT);
00067 #line 21 "insupd.pgc"
00068 
00069 if (sqlca.sqlwarn[0] == 'W') sqlprint();
00070 #line 21 "insupd.pgc"
00071 
00072 if (sqlca.sqlcode < 0) sqlprint();}
00073 #line 21 "insupd.pgc"
00074 
00075   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into insupd_test ( a , b ) values ( 3 , 3 ) returning a", ECPGt_EOIT, 
00076     ECPGt_int,&(i4),(long)1,(long)1,sizeof(int), 
00077     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
00078 #line 22 "insupd.pgc"
00079 
00080 if (sqlca.sqlwarn[0] == 'W') sqlprint();
00081 #line 22 "insupd.pgc"
00082 
00083 if (sqlca.sqlcode < 0) sqlprint();}
00084 #line 22 "insupd.pgc"
00085 
00086 
00087   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update insupd_test set a = a + 1 returning a", ECPGt_EOIT, 
00088     ECPGt_int,(i3),(long)1,(long)3,sizeof(int), 
00089     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
00090 #line 24 "insupd.pgc"
00091 
00092 if (sqlca.sqlwarn[0] == 'W') sqlprint();
00093 #line 24 "insupd.pgc"
00094 
00095 if (sqlca.sqlcode < 0) sqlprint();}
00096 #line 24 "insupd.pgc"
00097 
00098   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update insupd_test set ( a , b ) = ( 5 , 5 ) where a = 4", ECPGt_EOIT, ECPGt_EORT);
00099 #line 25 "insupd.pgc"
00100 
00101 if (sqlca.sqlwarn[0] == 'W') sqlprint();
00102 #line 25 "insupd.pgc"
00103 
00104 if (sqlca.sqlcode < 0) sqlprint();}
00105 #line 25 "insupd.pgc"
00106 
00107   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update insupd_test set a = 4 where a = 3", ECPGt_EOIT, ECPGt_EORT);
00108 #line 26 "insupd.pgc"
00109 
00110 if (sqlca.sqlwarn[0] == 'W') sqlprint();
00111 #line 26 "insupd.pgc"
00112 
00113 if (sqlca.sqlcode < 0) sqlprint();}
00114 #line 26 "insupd.pgc"
00115 ;
00116 
00117   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select a , b from insupd_test order by a", ECPGt_EOIT, 
00118     ECPGt_int,(i1),(long)1,(long)3,sizeof(int), 
00119     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
00120     ECPGt_int,(i2),(long)1,(long)3,sizeof(int), 
00121     ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
00122 #line 28 "insupd.pgc"
00123 
00124 if (sqlca.sqlwarn[0] == 'W') sqlprint();
00125 #line 28 "insupd.pgc"
00126 
00127 if (sqlca.sqlcode < 0) sqlprint();}
00128 #line 28 "insupd.pgc"
00129 
00130 
00131   printf("changes\n%d %d %d %d\n", i3[0], i3[1], i3[2], i4);
00132   printf("test\na b\n%d %d\n%d %d\n%d %d\n", i1[0], i2[0], i1[1], i2[1], i1[2], i2[2]);
00133 
00134   { ECPGdisconnect(__LINE__, "ALL");
00135 #line 33 "insupd.pgc"
00136 
00137 if (sqlca.sqlwarn[0] == 'W') sqlprint();
00138 #line 33 "insupd.pgc"
00139 
00140 if (sqlca.sqlcode < 0) sqlprint();}
00141 #line 33 "insupd.pgc"
00142 
00143 
00144   return 0;
00145 }