PostgreSQL Source Code git master
preproc-type.c
Go to the documentation of this file.
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
24typedef long mmInteger ;
25
26#line 6 "type.pgc"
27
28#line 6 "type.pgc"
29
30typedef char mmChar ;
31
32#line 7 "type.pgc"
33
34#line 7 "type.pgc"
35
36typedef short access ;
37
38#line 8 "type.pgc"
39
40#line 8 "type.pgc"
41 /* matches an unreserved SQL keyword */
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
52typedef char string[11];
53
54/* exec sql type c is char reference */
55#line 14 "type.pgc"
56
57typedef char* c;
58
59/* exec sql begin declare section */
60
61
62
63
64
65
66struct TBempl {
67#line 20 "type.pgc"
69
70#line 21 "type.pgc"
71 mmChar name [ 21 ] ;
72
73#line 22 "type.pgc"
75 } ;/* exec sql end declare section */
76#line 24 "type.pgc"
77
78
79int
80main (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}
bool ECPGdisconnect(int lineno, const char *connection_name)
Definition: connect.c:676
bool ECPGconnect(int lineno, int c, const char *name, const char *user, const char *passwd, const char *connection_name, int autocommit)
Definition: connect.c:255
@ ECPGst_normal
Definition: ecpgtype.h:97
@ ECPGt_EOIT
Definition: ecpgtype.h:62
@ ECPGt_short
Definition: ecpgtype.h:43
@ ECPGt_varchar
Definition: ecpgtype.h:48
@ ECPGt_long
Definition: ecpgtype.h:44
@ ECPGt_NO_INDICATOR
Definition: ecpgtype.h:64
@ ECPGt_EORT
Definition: ecpgtype.h:63
@ ECPGt_char
Definition: ecpgtype.h:43
bool ECPGdo(const int lineno, const int compat, const int force_indicator, const char *connection_name, const bool questionmarks, const int st, const char *query,...)
Definition: execute.c:2275
const char * str
#define free(a)
Definition: header.h:65
exit(1)
const void size_t len
#define printf(...)
Definition: port.h:245
char * c
short access
Definition: preproc-type.c:36
long mmInteger
Definition: preproc-type.c:24
access access_renamed
Definition: preproc-type.c:42
int main(void)
Definition: preproc-type.c:80
char mmChar
Definition: preproc-type.c:30
char * c
Definition: preproc-type.c:57
#define ECPGdebug(X, Y)
Definition: preproc-type.c:7
#define sqlca
Definition: sqlca.h:59
mmChar name[21]
Definition: preproc-type.c:71
access accs
Definition: preproc-type.c:74
mmInteger idnum
Definition: preproc-type.c:68
Definition: c.h:644
Datum varchar(PG_FUNCTION_ARGS)
Definition: varchar.c:609