00001
00002
00003 #include <ecpglib.h>
00004 #include <ecpgerrno.h>
00005 #include <sqlca.h>
00006
00007 #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
00008
00009 #line 1 "type.pgc"
00010 #include <stdio.h>
00011 #include <stdlib.h>
00012
00013
00014 #line 1 "regression.h"
00015
00016
00017
00018
00019
00020
00021 #line 4 "type.pgc"
00022
00023
00024 typedef long mmInteger ;
00025
00026 #line 6 "type.pgc"
00027
00028 #line 6 "type.pgc"
00029
00030 typedef char mmChar ;
00031
00032 #line 7 "type.pgc"
00033
00034 #line 7 "type.pgc"
00035
00036 typedef short mmSmallInt ;
00037
00038 #line 8 "type.pgc"
00039
00040 #line 8 "type.pgc"
00041
00042
00043
00044 #line 10 "type.pgc"
00045
00046 typedef char string[11];
00047
00048
00049 #line 13 "type.pgc"
00050
00051 typedef char* c;
00052
00053
00054
00055
00056
00057
00058
00059
00060 struct TBempl {
00061 #line 19 "type.pgc"
00062 mmInteger idnum ;
00063
00064 #line 20 "type.pgc"
00065 mmChar name [ 21 ] ;
00066
00067 #line 21 "type.pgc"
00068 mmSmallInt accs ;
00069 } ;
00070 #line 23 "type.pgc"
00071
00072
00073 int
00074 main (void)
00075 {
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086 #line 29 "type.pgc"
00087 struct TBempl empl ;
00088
00089 #line 30 "type.pgc"
00090 string str ;
00091
00092 #line 31 "type.pgc"
00093 c ptr = NULL ;
00094
00095 #line 36 "type.pgc"
00096 struct varchar {
00097 #line 34 "type.pgc"
00098 int len ;
00099
00100 #line 35 "type.pgc"
00101 char text [ 10 ] ;
00102 } vc ;
00103
00104 #line 37 "type.pgc"
00105
00106
00107
00108 #line 39 "type.pgc"
00109
00110 ECPGdebug (1, stderr);
00111
00112 empl.idnum = 1;
00113 { ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); }
00114 #line 43 "type.pgc"
00115
00116 if (sqlca.sqlcode)
00117 {
00118 printf ("connect error = %ld\n", sqlca.sqlcode);
00119 exit (sqlca.sqlcode);
00120 }
00121
00122 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table empl ( idnum integer , name char ( 20 ) , accs smallint , string1 char ( 10 ) , string2 char ( 10 ) , string3 char ( 10 ) )", ECPGt_EOIT, ECPGt_EORT);}
00123 #line 51 "type.pgc"
00124
00125 if (sqlca.sqlcode)
00126 {
00127 printf ("create error = %ld\n", sqlca.sqlcode);
00128 exit (sqlca.sqlcode);
00129 }
00130
00131 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into empl values ( 1 , 'user name' , 320 , 'first str' , 'second str' , 'third str' )", ECPGt_EOIT, ECPGt_EORT);}
00132 #line 58 "type.pgc"
00133
00134 if (sqlca.sqlcode)
00135 {
00136 printf ("insert error = %ld\n", sqlca.sqlcode);
00137 exit (sqlca.sqlcode);
00138 }
00139
00140 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select idnum , name , accs , string1 , string2 , string3 from empl where idnum = $1 ",
00141 ECPGt_long,&(empl.idnum),(long)1,(long)1,sizeof(long),
00142 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
00143 ECPGt_long,&(empl.idnum),(long)1,(long)1,sizeof(long),
00144 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
00145 ECPGt_char,&(empl.name),(long)21,(long)1,(21)*sizeof(char),
00146 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
00147 ECPGt_short,&(empl.accs),(long)1,(long)1,sizeof(short),
00148 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
00149 ECPGt_char,(str),(long)11,(long)1,(11)*sizeof(char),
00150 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
00151 ECPGt_char,&(ptr),(long)0,(long)1,(1)*sizeof(char),
00152 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
00153 ECPGt_varchar,&(vc),(long)10,(long)1,sizeof(struct varchar),
00154 ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
00155 #line 68 "type.pgc"
00156
00157 if (sqlca.sqlcode)
00158 {
00159 printf ("select error = %ld\n", sqlca.sqlcode);
00160 exit (sqlca.sqlcode);
00161 }
00162 printf ("id=%ld name='%s' accs=%d str='%s' ptr='%s' vc='%10.10s'\n", empl.idnum, empl.name, empl.accs, str, ptr, vc.text);
00163
00164 { ECPGdisconnect(__LINE__, "CURRENT");}
00165 #line 76 "type.pgc"
00166
00167
00168 free(ptr);
00169 exit (0);
00170 }