1
/* Processed by ecpg (regression mode) */
2
/* These include files are added by the preprocessor */
6
/* End of automatic include section */
7
#define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
15
#line 1 "regression.h"
25
int main(int argc, char* argv[]) {
34
{ ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); }
38
{ ECPGsetcommit(__LINE__, "on", NULL);}
41
/* exec sql whenever sql_warning sqlprint ; */
44
/* exec sql whenever sqlerror sqlprint ; */
48
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table My_Table ( Item1 int , Item2 text )", ECPGt_EOIT, ECPGt_EORT);
51
if (sqlca.sqlwarn[0] == 'W') sqlprint();
54
if (sqlca.sqlcode < 0) sqlprint();}
57
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table Log ( name text , w text )", ECPGt_EOIT, ECPGt_EORT);
60
if (sqlca.sqlwarn[0] == 'W') sqlprint();
63
if (sqlca.sqlcode < 0) sqlprint();}
67
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create function My_Table_Check ( ) returns trigger as $test$\
69
INSERT INTO Log VALUES(TG_NAME, TG_WHEN);\
71
END; $test$ language plpgsql", ECPGt_EOIT, ECPGt_EORT);
74
if (sqlca.sqlwarn[0] == 'W') sqlprint();
77
if (sqlca.sqlcode < 0) sqlprint();}
81
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create trigger My_Table_Check_Trigger before insert on My_Table for each row execute procedure My_Table_Check ( )", ECPGt_EOIT, ECPGt_EORT);
84
if (sqlca.sqlwarn[0] == 'W') sqlprint();
87
if (sqlca.sqlcode < 0) sqlprint();}
91
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into My_Table values ( 1234 , 'Some random text' )", ECPGt_EOIT, ECPGt_EORT);
94
if (sqlca.sqlwarn[0] == 'W') sqlprint();
97
if (sqlca.sqlcode < 0) sqlprint();}
100
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into My_Table values ( 5678 , 'The Quick Brown' )", ECPGt_EOIT, ECPGt_EORT);
103
if (sqlca.sqlwarn[0] == 'W') sqlprint();
106
if (sqlca.sqlcode < 0) sqlprint();}
109
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select name from Log limit 1", ECPGt_EOIT,
110
ECPGt_char,(text),(long)25,(long)1,(25)*sizeof(char),
111
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
114
if (sqlca.sqlwarn[0] == 'W') sqlprint();
117
if (sqlca.sqlcode < 0) sqlprint();}
120
printf("Trigger %s fired.\n", text);
122
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop trigger My_Table_Check_Trigger on My_Table", ECPGt_EOIT, ECPGt_EORT);
125
if (sqlca.sqlwarn[0] == 'W') sqlprint();
128
if (sqlca.sqlcode < 0) sqlprint();}
131
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop function My_Table_Check ( )", ECPGt_EOIT, ECPGt_EORT);
134
if (sqlca.sqlwarn[0] == 'W') sqlprint();
137
if (sqlca.sqlcode < 0) sqlprint();}
140
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table Log", ECPGt_EOIT, ECPGt_EORT);
143
if (sqlca.sqlwarn[0] == 'W') sqlprint();
146
if (sqlca.sqlcode < 0) sqlprint();}
149
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table My_Table", ECPGt_EOIT, ECPGt_EORT);
152
if (sqlca.sqlwarn[0] == 'W') sqlprint();
155
if (sqlca.sqlcode < 0) sqlprint();}
159
{ ECPGdisconnect(__LINE__, "ALL");
162
if (sqlca.sqlwarn[0] == 'W') sqlprint();
165
if (sqlca.sqlcode < 0) sqlprint();}