PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
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 mmSmallInt
 
typedef char string [11]
 
typedef char * c
 

Functions

int main (void)
 

Macro Definition Documentation

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

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

Referenced by main().

Typedef Documentation

typedef char* c

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

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

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

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

typedef char string[11]

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

Function Documentation

int main ( void  )

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

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, TBempl::name, NULL, sqlca, and varchar().

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 }
bool ECPGdisconnect(int lineno, const char *connection_name)
Definition: connect.c:669
#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
Datum varchar(PG_FUNCTION_ARGS)
Definition: varchar.c:593
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
#define NULL
Definition: c.h:229
Definition: c.h:439
#define ECPGdebug(X, Y)
Definition: preproc-type.c:7