PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
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 
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 mmSmallInt ;
37 
38 #line 8 "type.pgc"
39 
40 #line 8 "type.pgc"
41 
42 
43 /* exec sql type string is char [ 11 ] */
44 #line 10 "type.pgc"
45 
46 typedef char string[11];
47 
48 /* exec sql type c is char reference */
49 #line 13 "type.pgc"
50 
51 typedef char* c;
52 
53 /* exec sql begin declare section */
54 
55 
56 
57 
58 
59 
60 struct TBempl {
61 #line 19 "type.pgc"
63 
64 #line 20 "type.pgc"
65  mmChar name [ 21 ] ;
66 
67 #line 21 "type.pgc"
69  } ;/* exec sql end declare section */
70 #line 23 "type.pgc"
71 
72 
73 int
74 main (void)
75 {
76  /* exec sql begin declare section */
77 
78 
79 
80 
81 
82 
83 
84 
85 
86 #line 29 "type.pgc"
87  struct TBempl empl ;
88 
89 #line 30 "type.pgc"
90  string str ;
91 
92 #line 31 "type.pgc"
93  c ptr = NULL ;
94 
95 #line 36 "type.pgc"
96  struct varchar {
97 #line 34 "type.pgc"
98  int len ;
99 
100 #line 35 "type.pgc"
101  char text [ 10 ] ;
102  } vc ;
103 /* exec sql end declare section */
104 #line 37 "type.pgc"
105 
106 
107  /* exec sql var vc is [ 10 ] */
108 #line 39 "type.pgc"
109 
110  ECPGdebug (1, stderr);
111 
112  empl.idnum = 1;
113  { ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0); }
114 #line 43 "type.pgc"
115 
116  if (sqlca.sqlcode)
117  {
118  printf ("connect error = %ld\n", sqlca.sqlcode);
119  exit (sqlca.sqlcode);
120  }
121 
122  { 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);}
123 #line 51 "type.pgc"
124 
125  if (sqlca.sqlcode)
126  {
127  printf ("create error = %ld\n", sqlca.sqlcode);
128  exit (sqlca.sqlcode);
129  }
130 
131  { 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);}
132 #line 58 "type.pgc"
133 
134  if (sqlca.sqlcode)
135  {
136  printf ("insert error = %ld\n", sqlca.sqlcode);
137  exit (sqlca.sqlcode);
138  }
139 
140  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select idnum , name , accs , string1 , string2 , string3 from empl where idnum = $1 ",
141  ECPGt_long,&(empl.idnum),(long)1,(long)1,sizeof(long),
142  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
143  ECPGt_long,&(empl.idnum),(long)1,(long)1,sizeof( struct TBempl ),
144  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
145  ECPGt_char,&(empl.name),(long)21,(long)1,sizeof( struct TBempl ),
146  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
147  ECPGt_short,&(empl.accs),(long)1,(long)1,sizeof( struct TBempl ),
148  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
149  ECPGt_char,(str),(long)11,(long)1,(11)*sizeof(char),
150  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
151  ECPGt_char,&(ptr),(long)0,(long)1,(1)*sizeof(char),
152  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
153  ECPGt_varchar,&(vc),(long)10,(long)1,sizeof(struct varchar),
154  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
155 #line 68 "type.pgc"
156 
157  if (sqlca.sqlcode)
158  {
159  printf ("select error = %ld\n", sqlca.sqlcode);
160  exit (sqlca.sqlcode);
161  }
162  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);
163 
164  { ECPGdisconnect(__LINE__, "CURRENT");}
165 #line 76 "type.pgc"
166 
167 
168  free(ptr);
169  exit (0);
170 }
mmSmallInt accs
Definition: preproc-type.c:68
bool ECPGdisconnect(int lineno, const char *connection_name)
Definition: connect.c:669
char * c
Definition: preproc-type.c:51
#define sqlca
Definition: sqlca.h:59
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:2030
char mmChar
Definition: preproc-type.c:30
int main(void)
Definition: preproc-type.c:74
Datum varchar(PG_FUNCTION_ARGS)
Definition: varchar.c:593
short mmSmallInt
Definition: preproc-type.c:36
bool ECPGconnect(int lineno, int c, const char *name, const char *user, const char *passwd, const char *connection_name, int autocommit)
Definition: connect.c:271
char * c
#define free(a)
Definition: header.h:65
mmChar name[21]
Definition: preproc-type.c:65
Definition: c.h:433
long mmInteger
Definition: preproc-type.c:24
#define ECPGdebug(X, Y)
Definition: preproc-type.c:7
mmInteger idnum
Definition: preproc-type.c:62