Skip to content

Instantly share code, notes, and snippets.

@nikosvaggalis
Last active November 19, 2018 19:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nikosvaggalis/97a0936464cd94ea1f50f28c897295d9 to your computer and use it in GitHub Desktop.
Save nikosvaggalis/97a0936464cd94ea1f50f28c897295d9 to your computer and use it in GitHub Desktop.
Connecting the database to the outside world with Perl and Database Events
##Author:Nikos Vaggalis
##Licensed under Artistic License 1.0
##Accompanying code of the "Connecting the database to the outside world with Perl and Database Events"
##article on i-programmer.info
##https://www.i-programmer.info/programming/perl/12299-connecting-the-database-to-the-outside-world-with-perl-and-database-events.html
use strict;
use DBI;
my $dbh = DBI->connect ('DBI:IngresII:syntag::psnodb') || die "$DBI::errstr";
$dbh->do('REGISTER DBEVENT evn_insert_patientvisit');
$dbh->{RaiseError}=1;
$|=1;
my $data;
while (1) {
my $event_ref = $dbh->func( 'get_dbevent');
my $data=$event_ref->{text};
print "\n###CAUGHT EVENT #####\n";
print "With Data: ", $data,"\n";
my ($patient_id,$event_type,$event_id)=split ' ',$data;
if ($event_type eq 'A01') {
system("perl","patient_event_A01.pl",$patient_id,$event_type,$event_id);
}
elsif ($event_type eq 'A02') {
system("perl","./patient_event_A02.pl",$patient_id,$event_type,$event_id);
}
}
$dbh->disconnect();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment