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

Go to the source code of this file.

Macros

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

Functions

int main ()
 

Macro Definition Documentation

◆ ECPGdebug

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

Definition at line 7 of file sql-insupd.c.

Function Documentation

◆ main()

int main ( void  )

Definition at line 25 of file sql-insupd.c.

25  {
26  /* exec sql begin declare section */
27 
28 
29 #line 9 "insupd.pgc"
30  int i1 [ 3 ] , i2 [ 3 ] , i3 [ 3 ] , i4 ;
31 /* exec sql end declare section */
32 #line 10 "insupd.pgc"
33 
34 
35  ECPGdebug(1, stderr);
36  { ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , NULL, 0); }
37 #line 13 "insupd.pgc"
38 
39 
40  /* exec sql whenever sql_warning sqlprint ; */
41 #line 15 "insupd.pgc"
42 
43  /* exec sql whenever sqlerror sqlprint ; */
44 #line 16 "insupd.pgc"
45 
46 
47  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table insupd_test ( a int , b int )", ECPGt_EOIT, ECPGt_EORT);
48 #line 18 "insupd.pgc"
49 
50 if (sqlca.sqlwarn[0] == 'W') sqlprint();
51 #line 18 "insupd.pgc"
52 
53 if (sqlca.sqlcode < 0) sqlprint();}
54 #line 18 "insupd.pgc"
55 
56 
57  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into insupd_test ( a , b ) values ( 1 , 1 )", ECPGt_EOIT, ECPGt_EORT);
58 #line 20 "insupd.pgc"
59 
60 if (sqlca.sqlwarn[0] == 'W') sqlprint();
61 #line 20 "insupd.pgc"
62 
63 if (sqlca.sqlcode < 0) sqlprint();}
64 #line 20 "insupd.pgc"
65 
66  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into insupd_test ( a , b ) values ( 2 , 2 )", ECPGt_EOIT, ECPGt_EORT);
67 #line 21 "insupd.pgc"
68 
69 if (sqlca.sqlwarn[0] == 'W') sqlprint();
70 #line 21 "insupd.pgc"
71 
72 if (sqlca.sqlcode < 0) sqlprint();}
73 #line 21 "insupd.pgc"
74 
75  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into insupd_test ( a , b ) values ( 3 , 3 ) returning a", ECPGt_EOIT,
76  ECPGt_int,&(i4),(long)1,(long)1,sizeof(int),
77  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
78 #line 22 "insupd.pgc"
79 
80 if (sqlca.sqlwarn[0] == 'W') sqlprint();
81 #line 22 "insupd.pgc"
82 
83 if (sqlca.sqlcode < 0) sqlprint();}
84 #line 22 "insupd.pgc"
85 
86 
87  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update insupd_test set a = a + 1 returning a", ECPGt_EOIT,
88  ECPGt_int,(i3),(long)1,(long)3,sizeof(int),
89  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
90 #line 24 "insupd.pgc"
91 
92 if (sqlca.sqlwarn[0] == 'W') sqlprint();
93 #line 24 "insupd.pgc"
94 
95 if (sqlca.sqlcode < 0) sqlprint();}
96 #line 24 "insupd.pgc"
97 
98  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update insupd_test set ( a , b ) = ( 5 , 5 ) where a = 4", ECPGt_EOIT, ECPGt_EORT);
99 #line 25 "insupd.pgc"
100 
101 if (sqlca.sqlwarn[0] == 'W') sqlprint();
102 #line 25 "insupd.pgc"
103 
104 if (sqlca.sqlcode < 0) sqlprint();}
105 #line 25 "insupd.pgc"
106 
107  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update insupd_test set a = 4 where a = 3", ECPGt_EOIT, ECPGt_EORT);
108 #line 26 "insupd.pgc"
109 
110 if (sqlca.sqlwarn[0] == 'W') sqlprint();
111 #line 26 "insupd.pgc"
112 
113 if (sqlca.sqlcode < 0) sqlprint();}
114 #line 26 "insupd.pgc"
115 ;
116 
117  { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select a , b from insupd_test order by a", ECPGt_EOIT,
118  ECPGt_int,(i1),(long)1,(long)3,sizeof(int),
119  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
120  ECPGt_int,(i2),(long)1,(long)3,sizeof(int),
121  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
122 #line 28 "insupd.pgc"
123 
124 if (sqlca.sqlwarn[0] == 'W') sqlprint();
125 #line 28 "insupd.pgc"
126 
127 if (sqlca.sqlcode < 0) sqlprint();}
128 #line 28 "insupd.pgc"
129 
130 
131  printf("changes\n%d %d %d %d\n", i3[0], i3[1], i3[2], i4);
132  printf("test\na b\n%d %d\n%d %d\n%d %d\n", i1[0], i2[0], i1[1], i2[1], i1[2], i2[2]);
133 
134  { ECPGdisconnect(__LINE__, "ALL");
135 #line 33 "insupd.pgc"
136 
137 if (sqlca.sqlwarn[0] == 'W') sqlprint();
138 #line 33 "insupd.pgc"
139 
140 if (sqlca.sqlcode < 0) sqlprint();}
141 #line 33 "insupd.pgc"
142 
143 
144  return 0;
145 }
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_int
Definition: ecpgtype.h:44
@ ECPGt_NO_INDICATOR
Definition: ecpgtype.h:64
@ ECPGt_EORT
Definition: ecpgtype.h:63
void sqlprint(void)
Definition: error.c:334
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:2277
#define printf(...)
Definition: port.h:244
#define ECPGdebug(X, Y)
Definition: sql-insupd.c:7
#define sqlca
Definition: sqlca.h:59

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