aboutsummaryrefslogtreecommitdiff
path: root/src/interfaces/ecpg/test/expected/complex-test5.c
blob: 337a5d8984ba619a0489865f9337d6f5c71ec5fb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
/* Processed by ecpg (4.2.1) */
/* These include files are added by the preprocessor */
#include <ecpgtype.h>
#include <ecpglib.h>
#include <ecpgerrno.h>
#include <sqlca.h>
/* End of automatic include section */

#line 1 "test5.pgc"
#include <stdio.h>
#include <stdlib.h>


#line 1 "regression.h"






#line 4 "test5.pgc"


typedef long  mmInteger ;

#line 6 "test5.pgc"

#line 6 "test5.pgc"

typedef char  mmChar ;

#line 7 "test5.pgc"

#line 7 "test5.pgc"

typedef short  mmSmallInt ;

#line 8 "test5.pgc"

#line 8 "test5.pgc"


/* exec sql begin declare section */
 

   
   
   
   

struct TBempl { 
#line 13 "test5.pgc"
 mmInteger  idnum    ;
 
#line 14 "test5.pgc"
 mmChar  name [ 21 ]    ;
 
#line 15 "test5.pgc"
 mmSmallInt  accs    ;
 
#line 16 "test5.pgc"
 mmChar  byte [ 20 ]    ;
 } ;/* exec sql end declare section */
#line 18 "test5.pgc"


int
main (void)
{
  /* exec sql begin declare section */
    
     
   
  
	 
	 
   
  
#line 24 "test5.pgc"
 struct TBempl  empl    ;
 
#line 25 "test5.pgc"
 char * data   = "\\001\\155\\000\\212" ;
 
#line 30 "test5.pgc"
 union { 
#line 28 "test5.pgc"
 mmSmallInt  accs    ;
 
#line 29 "test5.pgc"
 char  t [ 2 ]    ;
 }  a    ;
/* exec sql end declare section */
#line 31 "test5.pgc"

  int i;

  ECPGdebug (1, stderr);

  empl.idnum = 1;
  { ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0); }
#line 37 "test5.pgc"

  if (sqlca.sqlcode)
    {
      printf ("connect error = %ld\n", sqlca.sqlcode);
      exit (sqlca.sqlcode);
    }

  { ECPGdo(__LINE__, 0, 1, NULL, "create  table empl ( idnum integer   , name char  ( 20 )    , accs smallint   , byte bytea   )    ", ECPGt_EOIT, ECPGt_EORT);}
#line 45 "test5.pgc"

  if (sqlca.sqlcode)
    {
      printf ("create error = %ld\n", sqlca.sqlcode);
      exit (sqlca.sqlcode);
    }

  { ECPGdo(__LINE__, 0, 1, NULL, "insert into empl values( 1 , 'first user' , 320 ,  ? ) ", 
	ECPGt_char,&(data),(long)0,(long)1,(1)*sizeof(char), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
#line 52 "test5.pgc"

  if (sqlca.sqlcode)
    {
      printf ("insert error = %ld\n", sqlca.sqlcode);
      exit (sqlca.sqlcode);
    }

  { ECPGdo(__LINE__, 0, 1, NULL, "select  name , accs , byte  from empl where idnum =  ?  ", 
	ECPGt_long,&(empl.idnum),(long)1,(long)1,sizeof(long), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
	ECPGt_char,(empl.name),(long)21,(long)1,(21)*sizeof(char), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_short,&(empl.accs),(long)1,(long)1,sizeof(short), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_char,(empl.byte),(long)20,(long)1,(20)*sizeof(char), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
#line 62 "test5.pgc"

  if (sqlca.sqlcode)
    {
      printf ("select error = %ld\n", sqlca.sqlcode);
      exit (sqlca.sqlcode);
    }
  printf ("name=%s, accs=%d byte=%s\n", empl.name, empl.accs, empl.byte);

  /* declare C  cursor  for select  name , accs , byte  from empl where idnum =  ?   */
#line 70 "test5.pgc"

  { ECPGdo(__LINE__, 0, 1, NULL, "declare C  cursor  for select  name , accs , byte  from empl where idnum =  ?  ", 
	ECPGt_long,&(empl.idnum),(long)1,(long)1,sizeof(long), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
#line 71 "test5.pgc"

  { ECPGdo(__LINE__, 0, 1, NULL, "fetch C", ECPGt_EOIT, 
	ECPGt_char,(empl.name),(long)21,(long)1,(21)*sizeof(char), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_short,&(empl.accs),(long)1,(long)1,sizeof(short), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_char,(empl.byte),(long)20,(long)1,(20)*sizeof(char), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
#line 72 "test5.pgc"

  if (sqlca.sqlcode)
    {
      printf ("fetch error = %ld\n", sqlca.sqlcode);
      exit (sqlca.sqlcode);
    }

  printf ("name=%s, accs=%d byte=%s\n", empl.name, empl.accs, empl.byte);

  memset(empl.name, 0, 21L);
  memset(empl.byte, '#', 20L);
  /* declare B  binary cursor  for select  name , accs , byte  from empl where idnum =  ?   */
#line 83 "test5.pgc"

  { ECPGdo(__LINE__, 0, 1, NULL, "declare B  binary cursor  for select  name , accs , byte  from empl where idnum =  ?  ", 
	ECPGt_long,&(empl.idnum),(long)1,(long)1,sizeof(long), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
#line 84 "test5.pgc"

  { ECPGdo(__LINE__, 0, 1, NULL, "fetch B", ECPGt_EOIT, 
	ECPGt_char,(empl.name),(long)21,(long)1,(21)*sizeof(char), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_short,&(a.accs),(long)1,(long)1,sizeof(short), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
	ECPGt_char,(empl.byte),(long)20,(long)1,(20)*sizeof(char), 
	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
#line 85 "test5.pgc"

  if (sqlca.sqlcode)
    {
      printf ("fetch error = %ld\n", sqlca.sqlcode);
      exit (sqlca.sqlcode);
    }

  { ECPGdo(__LINE__, 0, 1, NULL, "close B", ECPGt_EOIT, ECPGt_EORT);}
#line 92 "test5.pgc"


  /* do not print a.accs because big/little endian will have different outputs here */
  printf ("name=%s, byte=", empl.name);
  for (i=0; i<20; i++)
  {
	if (empl.byte[i] == '#')
		break;
	printf("(%o)", (unsigned char)empl.byte[i]);
  }
  printf("\n");
  { ECPGdisconnect(__LINE__, "CURRENT");}
#line 103 "test5.pgc"

  exit (0);
}