'ALL_TRIGGERS',
[qw/TRIGGER_BODY TABLE_OWNER TRIGGER_NAME/],
{
- $schema ? (OWNER => $schema) : (),
+ OWNER => $schema,
TABLE_NAME => $table || $source_name,
TRIGGERING_EVENT => { -like => '%INSERT%' }, # this will also catch insert_or_update
TRIGGER_TYPE => { -like => '%BEFORE%' }, # we care only about 'before' triggers
# to find all the triggers that mention the column in question a simple
# regex grep since the trigger_body above is a LONG and hence not searchable
+ # via -like
my @triggers = ( map
{ my %inf; @inf{qw/body schema name/} = @$_; \%inf }
( grep
)
);
- # extract all sequence names mentioned in each trigger
- for (@triggers) {
- $_->{sequences} = [ $_->{body} =~ / ( "? [\.\w\"\-]+ "? ) \. nextval /xig ];
- }
+ # extract all sequence names mentioned in each trigger, throw away
+ # triggers without apparent sequences
+ @triggers = map {
+ my @seqs = $_->{body} =~ / ( [\.\w\"\-]+ ) \. nextval /xig;
+ @seqs
+ ? { %$_, sequences => \@seqs }
+ : ()
+ ;
+ } @triggers;
my $chosen_trigger;