~ubuntu-branches/debian/sid/postgresql-9.3/sid

« back to all changes in this revision

Viewing changes to src/interfaces/ecpg/test/expected/preproc-define.c

  • Committer: Package Import Robot
  • Author(s): Martin Pitt
  • Date: 2013-05-08 05:39:52 UTC
  • Revision ID: package-import@ubuntu.com-20130508053952-1j7uilp7mjtrvq8q
Tags: upstream-9.3~beta1
ImportĀ upstreamĀ versionĀ 9.3~beta1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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 "define.pgc"
 
10
#include <stdlib.h>
 
11
#include <string.h>
 
12
#include <stdlib.h>
 
13
#include <stdio.h>
 
14
 
 
15
 
 
16
#line 1 "regression.h"
 
17
 
 
18
 
 
19
 
 
20
 
 
21
 
 
22
 
 
23
#line 6 "define.pgc"
 
24
 
 
25
 
 
26
/* exec sql whenever sqlerror  sqlprint ; */
 
27
#line 8 "define.pgc"
 
28
 
 
29
 
 
30
 
 
31
 
 
32
 
 
33
/* exec sql type intarray is int [ 6 ] */
 
34
#line 13 "define.pgc"
 
35
 
 
36
typedef int intarray[ 6];
 
37
 
 
38
int
 
39
main(void)
 
40
{
 
41
/* exec sql begin declare section */
 
42
 
 
43
           typedef char  string [ 8 ];
 
44
 
 
45
#line 21 "define.pgc"
 
46
 
 
47
         
 
48
           
 
49
                 
 
50
 
 
51
#line 22 "define.pgc"
 
52
 intarray amount ;
 
53
 
 
54
#line 23 "define.pgc"
 
55
 char name [ 6 ] [ 8 ] ;
 
56
 
 
57
#line 24 "define.pgc"
 
58
 char letter [ 6 ] [ 1 ] ;
 
59
 
 
60
#if 0
 
61
 
 
62
#line 26 "define.pgc"
 
63
 int not_used ;
 
64
 
 
65
#endif
 
66
/* exec sql end declare section */
 
67
#line 29 "define.pgc"
 
68
 
 
69
        int i,j;
 
70
 
 
71
        ECPGdebug(1, stderr);
 
72
 
 
73
        { ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); 
 
74
#line 34 "define.pgc"
 
75
 
 
76
if (sqlca.sqlcode < 0) sqlprint();}
 
77
#line 34 "define.pgc"
 
78
 
 
79
 
 
80
        { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table test ( name char ( 8 ) , amount int , letter char ( 1 ) )", ECPGt_EOIT, ECPGt_EORT);
 
81
#line 36 "define.pgc"
 
82
 
 
83
if (sqlca.sqlcode < 0) sqlprint();}
 
84
#line 36 "define.pgc"
 
85
 
 
86
        { ECPGtrans(__LINE__, NULL, "commit");
 
87
#line 37 "define.pgc"
 
88
 
 
89
if (sqlca.sqlcode < 0) sqlprint();}
 
90
#line 37 "define.pgc"
 
91
 
 
92
 
 
93
        { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into Test ( name , amount , letter ) values ( 'false' , 1 , 'f' )", ECPGt_EOIT, ECPGt_EORT);
 
94
#line 39 "define.pgc"
 
95
 
 
96
if (sqlca.sqlcode < 0) sqlprint();}
 
97
#line 39 "define.pgc"
 
98
 
 
99
        { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test ( name , amount , letter ) values ( 'true' , 2 , 't' )", ECPGt_EOIT, ECPGt_EORT);
 
100
#line 40 "define.pgc"
 
101
 
 
102
if (sqlca.sqlcode < 0) sqlprint();}
 
103
#line 40 "define.pgc"
 
104
 
 
105
        { ECPGtrans(__LINE__, NULL, "commit");
 
106
#line 41 "define.pgc"
 
107
 
 
108
if (sqlca.sqlcode < 0) sqlprint();}
 
109
#line 41 "define.pgc"
 
110
 
 
111
 
 
112
        { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select * from test", ECPGt_EOIT, 
 
113
        ECPGt_char,(name),(long)8,(long)6,(8)*sizeof(char), 
 
114
        ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 
115
        ECPGt_int,(amount),(long)1,(long)6,sizeof(int), 
 
116
        ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
 
117
        ECPGt_char,(letter),(long)1,(long)6,(1)*sizeof(char), 
 
118
        ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
 
119
#line 43 "define.pgc"
 
120
 
 
121
if (sqlca.sqlcode < 0) sqlprint();}
 
122
#line 43 "define.pgc"
 
123
 
 
124
 
 
125
        for (i=0, j=sqlca.sqlerrd[2]; i<j; i++)
 
126
        {
 
127
                /* exec sql begin declare section */
 
128
                    
 
129
                   
 
130
                
 
131
#line 48 "define.pgc"
 
132
 char n [ 8 ] , l = letter [ i ] [ 0 ] ;
 
133
 
 
134
#line 49 "define.pgc"
 
135
 int a = amount [ i ] ;
 
136
/* exec sql end declare section */
 
137
#line 50 "define.pgc"
 
138
 
 
139
 
 
140
                strncpy(n, name[i],  8);
 
141
                printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n", i, n, i, a, i, l);
 
142
        }
 
143
 
 
144
        { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table test", ECPGt_EOIT, ECPGt_EORT);
 
145
#line 56 "define.pgc"
 
146
 
 
147
if (sqlca.sqlcode < 0) sqlprint();}
 
148
#line 56 "define.pgc"
 
149
 
 
150
        { ECPGtrans(__LINE__, NULL, "commit");
 
151
#line 57 "define.pgc"
 
152
 
 
153
if (sqlca.sqlcode < 0) sqlprint();}
 
154
#line 57 "define.pgc"
 
155
 
 
156
        { ECPGdisconnect(__LINE__, "CURRENT");
 
157
#line 58 "define.pgc"
 
158
 
 
159
if (sqlca.sqlcode < 0) sqlprint();}
 
160
#line 58 "define.pgc"
 
161
 
 
162
 
 
163
        return (0);
 
164
}