PostgreSQL Source Code  git master
preproc-define.c File Reference
#include <ecpglib.h>
#include <ecpgerrno.h>
#include <sqlca.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
Include dependency graph for preproc-define.c:

Go to the source code of this file.

Macros

#define ECPGdebug(X, Y)   ECPGdebug((X)+100,(Y))
 

Typedefs

typedef int intarray[6]
 

Functions

int main (void)
 

Macro Definition Documentation

◆ ECPGdebug

#define ECPGdebug (   X,
 
)    ECPGdebug((X)+100,(Y))

Definition at line 7 of file preproc-define.c.

Referenced by main().

Typedef Documentation

◆ intarray

typedef int intarray[6]

Definition at line 35 of file preproc-define.c.

Function Documentation

◆ main()

int main ( void  )

Definition at line 38 of file preproc-define.c.

References ECPGconnect(), ECPGdebug, ECPGdisconnect(), ECPGdo(), ECPGst_normal, ECPGt_char, ECPGt_EOIT, ECPGt_EORT, ECPGt_int, ECPGt_NO_INDICATOR, ECPGtrans(), i, name, printf, sqlca, and sqlprint().

39 {
40 /* exec sql begin declare section */
41 
42 
43  typedef char string [ 8 ];
44 
45 #line 21 "define.pgc"
46 
47 
48 
49 
50 
51 
52 
53 
54 
55 
56 
57 
58 
59 
60 
61 
62 
63 
64 
65 
66 
67 #line 22 "define.pgc"
68  intarray amount ;
69 
70 #line 23 "define.pgc"
71  char name [ 6 ] [ 8 ] ;
72 
73 #line 36 "define.pgc"
74  char letter [ 6 ] [ 1 ] ;
75 
76 #if 0
77 
78 #line 38 "define.pgc"
79  int not_used ;
80 
81 #endif
82 /* exec sql end declare section */
83 #line 45 "define.pgc"
84 
85  int i,j;
86 
87  ECPGdebug(1, stderr);
88 
89  { ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0);
90 #line 50 "define.pgc"
91 
92 if (sqlca.sqlcode < 0) sqlprint();}
93 #line 50 "define.pgc"
94 
95 
96  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table test ( name char ( 8 ) , amount int , letter char ( 1 ) )", ECPGt_EOIT, ECPGt_EORT);
97 #line 52 "define.pgc"
98 
99 if (sqlca.sqlcode < 0) sqlprint();}
100 #line 52 "define.pgc"
101 
102  { ECPGtrans(__LINE__, NULL, "commit");
103 #line 53 "define.pgc"
104 
105 if (sqlca.sqlcode < 0) sqlprint();}
106 #line 53 "define.pgc"
107 
108 
109  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into Test ( name , amount , letter ) values ( 'false' , 1 , 'f' )", ECPGt_EOIT, ECPGt_EORT);
110 #line 55 "define.pgc"
111 
112 if (sqlca.sqlcode < 0) sqlprint();}
113 #line 55 "define.pgc"
114 
115  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into test ( name , amount , letter ) values ( 'true' , 2 , 't' )", ECPGt_EOIT, ECPGt_EORT);
116 #line 56 "define.pgc"
117 
118 if (sqlca.sqlcode < 0) sqlprint();}
119 #line 56 "define.pgc"
120 
121  { ECPGtrans(__LINE__, NULL, "commit");
122 #line 57 "define.pgc"
123 
124 if (sqlca.sqlcode < 0) sqlprint();}
125 #line 57 "define.pgc"
126 
127 
128  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select * from test", ECPGt_EOIT,
129  ECPGt_char,(name),(long)8,(long)6,(8)*sizeof(char),
130  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
131  ECPGt_int,(amount),(long)1,(long)6,sizeof(int),
132  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
133  ECPGt_char,(letter),(long)1,(long)6,(1)*sizeof(char),
134  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
135 #line 59 "define.pgc"
136 
137 if (sqlca.sqlcode < 0) sqlprint();}
138 #line 59 "define.pgc"
139 
140 
141  for (i=0, j=sqlca.sqlerrd[2]; i<j; i++)
142  {
143  /* exec sql begin declare section */
144 
145 
146 
147 
148 #line 64 "define.pgc"
149  string n ;
150 
151 #line 65 "define.pgc"
152  char l = letter [ i ] [ 0 ] ;
153 
154 #line 66 "define.pgc"
155  int a = amount [ i ] ;
156 /* exec sql end declare section */
157 #line 67 "define.pgc"
158 
159 
160  strncpy(n, name[i], 8);
161  printf("name[%d]=%8.8s\tamount[%d]=%d\tletter[%d]=%c\n", i, n, i, a, i, l);
162  }
163 
164  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table test", ECPGt_EOIT, ECPGt_EORT);
165 #line 73 "define.pgc"
166 
167 if (sqlca.sqlcode < 0) sqlprint();}
168 #line 73 "define.pgc"
169 
170  { ECPGtrans(__LINE__, NULL, "commit");
171 #line 74 "define.pgc"
172 
173 if (sqlca.sqlcode < 0) sqlprint();}
174 #line 74 "define.pgc"
175 
176  { ECPGdisconnect(__LINE__, "CURRENT");
177 #line 75 "define.pgc"
178 
179 if (sqlca.sqlcode < 0) sqlprint();}
180 #line 75 "define.pgc"
181 
182 
183  return 0;
184 }
bool ECPGdisconnect(int lineno, const char *connection_name)
Definition: connect.c:659
#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:2287
#define printf(...)
Definition: port.h:222
int intarray[6]
#define ECPGdebug(X, Y)
Definition: preproc-define.c:7
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
void sqlprint(void)
Definition: error.c:335
bool ECPGtrans(int lineno, const char *connection_name, const char *transaction)
Definition: misc.c:198
const char * name
Definition: encode.c:515
int i