On 12/10/2010 6:19 PM, Tim Peiffer wrote: > How do you expose a database handle in later rules? Do you have an > example using the module method you offer?
Well, it obviously depends on your specific requirements, but hopefully this extremely contrived pseudo-code gives you an idea.... package MySec; my $dbh; sub init { if (not defined $dbh) { $dbh = DBI->new(...); } } sub query { my $q = shift; my $result; if (defined $dbh) { # run query via $dbh } return $result == 1; } sub update { my $param = shift; if (defined $dbh) { # update something using $param } 1; } 1; ===================================================== type=Single ptype=RegExp pattern=(\d+) something something desc=something squared with $1 context= =(MySec::query("select blah where foo = '$1'") action=write "$1 matched my query"; eval %o (MySEC::update($1)) ===================================================== I'm sure there are multiple flaws in this, but the idea you are looking for is here -- the DB handle is allocated/connected in your init call, and you can create other routines in that scope that manipulate and use the DB handle. The routines can be called as context checks and they can be called via eval. You could also use them in PerlFunc patterns. Regards, Mark ------------------------------------------------------------------------------ Oracle to DB2 Conversion Guide: Learn learn about native support for PL/SQL, new data types, scalar functions, improved concurrency, built-in packages, OCI, SQL*Plus, data movement tools, best practices and more. http://p.sf.net/sfu/oracle-sfdev2dev _______________________________________________ Simple-evcorr-users mailing list Simple-evcorr-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/simple-evcorr-users