Skip to content

Instantly share code, notes, and snippets.

@nikosvaggalis
Last active November 19, 2018 19:59
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/1465a785944d0ad98fa99dd34e74ce58 to your computer and use it in GitHub Desktop.
Save nikosvaggalis/1465a785944d0ad98fa99dd34e74ce58 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
*/
create dbevent evn_insert_patientvisit;
grant register on dbevent evn_insert_patientvisit to user;
grant raise on dbevent evn_insert_patientvisit to user;
create procedure db_insert_patientvisit
(
patient_id = integer not null,
event_type = char(3) not null ,
event_id = integer not null
)
AS
DECLARE data VARCHAR(200) not NULL;
BEGIN
data=varchar(patient_id)+' '+event_type+' '+varchar(event_id);
RAISE DBEVENT evn_insert_patientvisit data;
END;
create rule ru_insert_patientvisit after insert on patientvisit
execute procedure db_insert_patientvisit (
patient_id = new.patient_id,
event_type = new.event_type,
event_id = new.event_id
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment