@@ -97,6 +97,13 @@ pguserval := (SELECT current_user);
97
97
else
98
98
column_value = ' 1' ;
99
99
end if;
100
+ when
101
+ column_name = ' social_email_verified' then
102
+ if column_value = ' false' then
103
+ column_value = ' f' ;
104
+ else
105
+ column_value = ' t' ;
106
+ end if;
100
107
when
101
108
column_name = ' create_date' then
102
109
column_value := (select to_char (column_value::timestamp , ' YYYY-MM-DD HH24:MI:SS.MS' ));
@@ -119,7 +126,7 @@ pguserval := (SELECT current_user);
119
126
-- logtime := (select date_display_tz());
120
127
logtime := (SELECT to_char (now()::timestamptz at time zone ' UTC' , ' YYYY-MM-DD"T"HH24:MI:SS"Z"' ));
121
128
122
- payloadseqid := (select nextval(' payloadsequence' ::regclass));
129
+ payloadseqid := (select nextval(' common_oltp. payloadsequence' ::regclass));
123
130
124
131
uniquecolumn := (SELECT c .column_name
125
132
FROM information_schema .key_column_usage AS c
@@ -155,11 +162,18 @@ pguserval := (SELECT current_user);
155
162
END;
156
163
$body$ LANGUAGE plpgsql
157
164
165
+ -- CREATE TRIGGER "pg_email_trigger"
166
+ -- AFTER INSERT OR DELETE OR UPDATE ON email
167
+ -- FOR EACH ROW
168
+ -- EXECUTE PROCEDURE notify_trigger_common_oltp('user_id', 'email_id', 'email_type_id', 'address', 'primary_ind', 'status_id');
169
+
158
170
CREATE TRIGGER "pg_email_trigger "
159
171
AFTER INSERT OR DELETE OR UPDATE ON email
160
172
FOR EACH ROW
161
- EXECUTE PROCEDURE notify_trigger_common_oltp(' user_id' , ' email_id' , ' email_type_id' , ' address' , ' primary_ind' , ' status_id' );
162
-
173
+ EXECUTE PROCEDURE notify_trigger_common_oltp(' user_id' , ' email_id' , ' email_type_id' , ' address' , ' create_date' , ' modify_date' , ' primary_ind' , ' status_id' );
174
+
175
+
176
+
163
177
CREATE TRIGGER "pg_security_user_trigger "
164
178
AFTER INSERT OR DELETE OR UPDATE ON security_user
165
179
FOR EACH ROW
@@ -221,6 +235,42 @@ AFTER INSERT OR DELETE OR UPDATE ON achievement_type_lu
221
235
FOR EACH ROW
222
236
EXECUTE PROCEDURE notify_trigger_common_oltp(' achievement_type_id' ,' achievement_type_desc' );
223
237
238
+
239
+ CREATE OR REPLACE FUNCTION "common_oltp "." proc_email_update" () RETURNS trigger
240
+ VOLATILE
241
+ AS $body$
242
+ DECLARE
243
+ pguserval TEXT ;
244
+ BEGIN
245
+ if (OLD .email_type_id != NEW .email_type_id ) then
246
+ insert into common_oltp .audit_user (column_name, old_value, new_value, user_id)
247
+ values (' EMAIL_TYPE' , OLD .email_type_id , NEW .email_type_id , OLD .user_id );
248
+ End If;
249
+
250
+ if (OLD .status_id != NEW .status_id ) then
251
+ insert into common_oltp .audit_user (column_name, old_value, new_value, user_id)
252
+ values (' EMAIL_STATUS' , OLD .status_id , NEW .status_id , OLD .user_id );
253
+ End If;
254
+
255
+ if (OLD .address != NEW .address ) then
256
+ insert into common_oltp .audit_user (column_name, old_value, new_value, user_id)
257
+ values (' EMAIL_ADDRESS' , OLD .address , NEW .address , OLD .user_id );
258
+ End If;
259
+
260
+ if (OLD .primary_ind != NEW .primary_ind ) then
261
+ insert into common_oltp .audit_user (column_name, old_value, new_value, user_id)
262
+ values (' EMAIL_PRIMARY_IND' , OLD .primary_ind , NEW .primary_ind , OLD .user_id );
263
+ End If;
264
+
265
+ pguserval := (SELECT current_user );
266
+ if pguserval != ' pgsyncuser' then
267
+ NEW .modify_date = current_timestamp ;
268
+ end if;
269
+
270
+
271
+ RETURN NEW;
272
+ END;
273
+ $body$ LANGUAGE plpgsql
224
274
225
275
CREATE SEQUENCE payloadsequence INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807
226
276
START WITH 1 NO CYCLE;
@@ -349,7 +399,7 @@ BEGIN
349
399
END LOOP;
350
400
-- logtime := (select date_display_tz());
351
401
logtime := (SELECT to_char (now()::timestamptz at time zone ' UTC' , ' YYYY-MM-DD"T"HH24:MI:SS"Z"' ));
352
- payloadseqid := (select nextval(' payloadsequence' ::regclass));
402
+ payloadseqid := (select nextval(' common_oltp. payloadsequence' ::regclass));
353
403
354
404
uniquecolumn := (SELECT c .column_name
355
405
FROM information_schema .key_column_usage AS c
@@ -390,15 +440,57 @@ CREATE TRIGGER "pg_algo_rating"
390
440
FOR EACH ROW
391
441
EXECUTE PROCEDURE notify_trigger_informixoltp(' coder_id' , ' rating' , ' vol' , ' round_id' , ' num_ratings' , ' algo_rating_type_id' , ' modify_date' );
392
442
443
+ -- CREATE TRIGGER "pg_coder"
444
+ -- AFTER INSERT OR DELETE OR UPDATE ON coder
445
+ -- FOR EACH ROW
446
+ -- EXECUTE PROCEDURE notify_trigger_informixoltp('coder_id', 'quote', 'coder_type_id', 'comp_country_code', 'display_quote', 'quote_location', 'quote_color', 'display_banner', 'banner_style');
393
447
CREATE TRIGGER "pg_coder "
394
448
AFTER INSERT OR DELETE OR UPDATE ON coder
395
449
FOR EACH ROW
396
- EXECUTE PROCEDURE notify_trigger_informixoltp(' coder_id' , ' quote' , ' coder_type_id' , ' comp_country_code' , ' display_quote' , ' quote_location' , ' quote_color' , ' display_banner' , ' banner_style' );
397
-
450
+ EXECUTE PROCEDURE notify_trigger_informixoltp(' coder_id' , ' member_since' , ' quote' , ' modify_date' , ' language_id' , ' coder_type_id' , ' date_of_birth' , ' home_country_code' , ' comp_country_code' , ' contact_date' , ' display_quote' , ' quote_location' , ' quote_color' , ' display_banner' , ' banner_style' );
451
+
452
+
398
453
CREATE TRIGGER "pg_coder_referral_trigger "
399
454
AFTER INSERT OR DELETE OR UPDATE ON coder_referral
400
455
FOR EACH ROW
401
456
EXECUTE PROCEDURE notify_trigger_informixoltp(' coder_id' , ' referral_id' ,' reference_id' ,' other' );
457
+
458
+
459
+ CREATE OR REPLACE FUNCTION "informixoltp "." proc_coder_update" () RETURNS trigger
460
+ VOLATILE
461
+ AS $body$
462
+ DECLARE
463
+ pguserval TEXT ;
464
+ begin
465
+ if (OLD .quote != NEW .quote ) then
466
+ insert into audit_coder (column_name, old_value, new_value, user_id)
467
+ values (' QUOTE' , OLD .quote , NEW .quote , OLD .coder_id );
468
+ end if;
469
+
470
+ if (OLD .coder_type_id != NEW .coder_type_id ) then
471
+ insert into audit_coder (column_name, old_value, new_value, user_id)
472
+ values (' CODER_TYPE' , OLD .coder_type_id , NEW .coder_type_id , OLD .coder_id );
473
+ end if;
474
+ if (OLD .language_id != NEW .language_id ) then
475
+ insert into audit_coder (column_name, old_value, new_value, user_id)
476
+ values (' LANGUAGE' , OLD .language_id , NEW .language_id , OLD .coder_id );
477
+ end if;
478
+ if (OLD .comp_country_code != NEW .comp_country_code ) then
479
+ insert into audit_coder (column_name, old_value, new_value, user_id)
480
+ values (' COMP_COUNTRY' , OLD .comp_country_code , NEW .comp_country_code , OLD .coder_id );
481
+ end if;
482
+ pguserval := (SELECT current_user );
483
+ if pguserval != ' pgsyncuser' then
484
+ -- RAISE info 'current_user';
485
+ -- raise notice 'inside current_user : %', current_user;
486
+ -- update coder set modify_date = current_timestamp where coder_id = OLD.coder_id;
487
+ NEW .modify_date = current_timestamp ;
488
+ end if;
489
+
490
+ return NEW;
491
+ end ;
492
+ $body$ LANGUAGE plpgsql
493
+
402
494
403
495
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA common_oltp,informixoltp, corporate_oltp,tcs_catalog, time_oltp TO coder;
404
496
GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA common_oltp,informixoltp, corporate_oltp,tcs_catalog, time_oltp TO coder;
0 commit comments