2015-10-14 8:46 GMT+03:00 Bond Masuda <bond.mas...@jlbond.com>:

...


> When I run my code, I get this runtime error:
>
> Calling code 'CODE(0x1b73580)' and setting variable '%dbh'
> Variable '%dbh' set to 'DBI::db=HASH(0x24e7fd0)'
> INFO: connected to in-memory sqlite3 database.
> Calling code 'CODE(0x20bcfe8)' and setting variable '%ret'
> Code 'CODE(0x20bcfe8)' runtime error: Can't locate object method "do"
> via package "DBI::db=HASH(0x24e7fd0)" (perhaps you forgot to load
> "DBI::db=HASH(0x24e7fd0)"?) at (eval 10) line 1.
>
>
> I'm not sure why this is failing, but my guess is that I can't pass the
> database object handle via the %dbh action variable. Any ideas on how to
> accomplish this? What's the best way to setup to pass around data
> structure that all the rules can see when using perl mini-programs (via
> lcall or eval)?
>

After a return value from Perl code has been assigned to a variable, in
most cases the value of a variable will be substituted as a string (the
only exception is the 'call' action, where one of the parameters is
expected to be a variable that holds a code reference). Therefore, if you
would need to set up some interaction between Perl code in different rules,
Perl global variables are the best way for accomplishing that.

For example, in your rule example you could change
my $ret = $dbh->do($sql);
to
$handle = $dbh->do($sql);
where $handle is a global variable that will continue to exist after the
exit from the function, and can be accessed in the future from other perl
code as well.


> BTW, I've seen the example here
> (
> http://simple-evcorr.sourceforge.net/SEC-tutorial/article-part2.html#DATABASEINTEGRATION
> ),
> but I would prefer not having a separate process to handle the database.
>

The tutorial you are referring to is quite old and dates back to 2004, and
most examples in this document have been created for sec version 2.2. This
version was obsoleted in 2005 and many things can be done more efficiently
with newer versions of sec. Therefore, I wouldn't recommend to consider
this tutorial as a best practice, but rather as an example how things could
be done without the use of more recent sec features.

kind regards,
risto


> Thanks,
> Bond
>
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> Simple-evcorr-users mailing list
> Simple-evcorr-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/simple-evcorr-users
>
------------------------------------------------------------------------------
_______________________________________________
Simple-evcorr-users mailing list
Simple-evcorr-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/simple-evcorr-users

Reply via email to