| 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 "type.pgc" |
| 10 |
#include <stdio.h> |
| 11 |
#include <stdlib.h> |
| 12 |
|
| 13 |
|
| 14 |
#line 1 "regression.h" |
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
#line 4 "type.pgc" |
| 22 |
|
| 23 |
|
| 24 |
typedef long mmInteger ; |
| 25 |
|
| 26 |
#line 6 "type.pgc" |
| 27 |
|
| 28 |
#line 6 "type.pgc" |
| 29 |
|
| 30 |
typedef char mmChar ; |
| 31 |
|
| 32 |
#line 7 "type.pgc" |
| 33 |
|
| 34 |
#line 7 "type.pgc" |
| 35 |
|
| 36 |
typedef short access ; |
| 37 |
|
| 38 |
#line 8 "type.pgc" |
| 39 |
|
| 40 |
#line 8 "type.pgc" |
| 41 |
/* matches an unreserved SQL keyword */ |
| 42 |
typedef access access_renamed ; |
| 43 |
|
| 44 |
#line 9 "type.pgc" |
| 45 |
|
| 46 |
#line 9 "type.pgc" |
| 47 |
|
| 48 |
|
| 49 |
/* exec sql type string is char [ 11 ] */ |
| 50 |
#line 11 "type.pgc" |
| 51 |
|
| 52 |
typedef char string[11]; |
| 53 |
|
| 54 |
/* exec sql type c is char reference */ |
| 55 |
#line 14 "type.pgc" |
| 56 |
|
| 57 |
typedef char* c; |
| 58 |
|
| 59 |
/* exec sql begin declare section */ |
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
struct TBempl { |
| 67 |
#line 20 "type.pgc" |
| 68 |
mmInteger idnum ; |
| 69 |
|
| 70 |
#line 21 "type.pgc" |
| 71 |
mmChar name [ 21 ] ; |
| 72 |
|
| 73 |
#line 22 "type.pgc" |
| 74 |
access accs ; |
| 75 |
} ;/* exec sql end declare section */ |
| 76 |
#line 24 "type.pgc" |
| 77 |
|
| 78 |
|
| 79 |
int |
| 80 |
main (void) |
| 81 |
{ |
| 82 |
/* exec sql begin declare section */ |
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
#line 30 "type.pgc" |
| 94 |
struct TBempl empl ; |
| 95 |
|
| 96 |
#line 31 "type.pgc" |
| 97 |
string str ; |
| 98 |
|
| 99 |
#line 32 "type.pgc" |
| 100 |
access accs_val = 320 ; |
| 101 |
|
| 102 |
#line 33 "type.pgc" |
| 103 |
c ptr = NULL ; |
| 104 |
|
| 105 |
#line 38 "type.pgc" |
| 106 |
struct varchar { |
| 107 |
#line 36 "type.pgc" |
| 108 |
int len ; |
| 109 |
|
| 110 |
#line 37 "type.pgc" |
| 111 |
char text [ 10 ] ; |
| 112 |
} vc ; |
| 113 |
/* exec sql end declare section */ |
| 114 |
#line 39 "type.pgc" |
| 115 |
|
| 116 |
|
| 117 |
/* exec sql var vc is [ 10 ] */ |
| 118 |
#line 41 "type.pgc" |
| 119 |
|
| 120 |
ECPGdebug (1, stderr); |
| 121 |
|
| 122 |
empl.idnum = 1; |
| 123 |
{ ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0); } |
| 124 |
#line 45 "type.pgc" |
| 125 |
|
| 126 |
if (sqlca.sqlcode) |
| 127 |
{ |
| 128 |
printf ("connect error = %ld\n", sqlca.sqlcode); |
| 129 |
exit (sqlca.sqlcode); |
| 130 |
} |
| 131 |
|
| 132 |
{ 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);} |
| 133 |
#line 53 "type.pgc" |
| 134 |
|
| 135 |
if (sqlca.sqlcode) |
| 136 |
{ |
| 137 |
printf ("create error = %ld\n", sqlca.sqlcode); |
| 138 |
exit (sqlca.sqlcode); |
| 139 |
} |
| 140 |
|
| 141 |
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into empl values ( 1 , 'user name' , $1 , 'first str' , 'second str' , 'third str' )", |
| 142 |
ECPGt_short,&(accs_val),(long)1,(long)1,sizeof(short), |
| 143 |
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);} |
| 144 |
#line 60 "type.pgc" |
| 145 |
|
| 146 |
if (sqlca.sqlcode) |
| 147 |
{ |
| 148 |
printf ("insert error = %ld\n", sqlca.sqlcode); |
| 149 |
exit (sqlca.sqlcode); |
| 150 |
} |
| 151 |
|
| 152 |
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select idnum , name , accs , string1 , string2 , string3 from empl where idnum = $1 ", |
| 153 |
ECPGt_long,&(empl.idnum),(long)1,(long)1,sizeof(long), |
| 154 |
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, |
| 155 |
ECPGt_long,&(empl.idnum),(long)1,(long)1,sizeof( struct TBempl ), |
| 156 |
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, |
| 157 |
ECPGt_char,&(empl.name),(long)21,(long)1,sizeof( struct TBempl ), |
| 158 |
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, |
| 159 |
ECPGt_short,&(empl.accs),(long)1,(long)1,sizeof( struct TBempl ), |
| 160 |
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, |
| 161 |
ECPGt_char,(str),(long)11,(long)1,(11)*sizeof(char), |
| 162 |
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, |
| 163 |
ECPGt_char,&(ptr),(long)0,(long)1,(1)*sizeof(char), |
| 164 |
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, |
| 165 |
ECPGt_varchar,&(vc),(long)10,(long)1,sizeof(struct varchar), |
| 166 |
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);} |
| 167 |
#line 70 "type.pgc" |
| 168 |
|
| 169 |
if (sqlca.sqlcode) |
| 170 |
{ |
| 171 |
printf ("select error = %ld\n", sqlca.sqlcode); |
| 172 |
exit (sqlca.sqlcode); |
| 173 |
} |
| 174 |
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); |
| 175 |
|
| 176 |
{ ECPGdisconnect(__LINE__, "CURRENT");} |
| 177 |
#line 78 "type.pgc" |
| 178 |
|
| 179 |
|
| 180 |
free(ptr); |
| 181 |
exit (0); |
| 182 |
} |