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

Go to the source code of this file.

Data Structures

struct  TBempl
 

Macros

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

Typedefs

typedef long mmInteger
 
typedef char mmChar
 
typedef short access
 
typedef access access_renamed
 
typedef char string[11]
 
typedef char * c
 

Functions

int main (void)
 

Macro Definition Documentation

◆ ECPGdebug

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

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

Typedef Documentation

◆ access

typedef short access

Definition at line 36 of file preproc-type.c.

◆ access_renamed

Definition at line 42 of file preproc-type.c.

◆ c

typedef char* c

Definition at line 57 of file preproc-type.c.

◆ mmChar

typedef char mmChar

Definition at line 30 of file preproc-type.c.

◆ mmInteger

typedef long mmInteger

Definition at line 24 of file preproc-type.c.

◆ string

typedef char string[11]

Definition at line 52 of file preproc-type.c.

Function Documentation

◆ main()

int main ( void  )

Definition at line 80 of file preproc-type.c.

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
const void size_t len
#define printf(...)
Definition: port.h:245
char * c
short access
Definition: preproc-type.c:36
#define ECPGdebug(X, Y)
Definition: preproc-type.c:7
#define sqlca
Definition: sqlca.h:59
Definition: c.h:658
Datum varchar(PG_FUNCTION_ARGS)
Definition: varchar.c:609

References TBempl::accs, ECPGconnect(), ECPGdebug, ECPGdisconnect(), ECPGdo(), ECPGst_normal, ECPGt_char, ECPGt_EOIT, ECPGt_EORT, ECPGt_long, ECPGt_NO_INDICATOR, ECPGt_short, ECPGt_varchar, free, TBempl::idnum, len, TBempl::name, printf, sqlca, str, and varchar().