Working with CGI::App and CGI::App::Plugin::DBH. I need to use multiple databases because my app has to query them both. Here is an extract of my script.
sub cgiapp_init {
my $self = shift;
# Configure Database handler for the entire app
$ENV{'ORACLE_HOME'} = $self->cfg('OracleHome');
$self->dbh_config('db1', [ $self->cfg('db1dsn'), $self->cfg('db1dbus
+er'), $self->cfg('db1pass') ] );
$self->dbh_config('db2', [ $self->cfg('db2dsn'), $self->cfg('db2li
+vusr'), $self->cfg('db2pass') ] );
}
sub Login {
my $self = shift;
my $q = $self->query();
my $strSQL = 'SELECT FOO, BAR FROM TABLE WHERE Foo = ?';
my $dbh = $self->dbh->('db1');
my $sth = $dbh->prepare($strSQL) or die "Can't prepair stateme
+nt: $self->DBI::errstr";
$sth->execute($baz);
....
I get the error:
Error executing run mode 'Login': must call dbh_config() before callin
+g dbh().
I've read the Docs and think I'm doing it right, I don't know how to debug this. Can anyone give an example of using CGI::App like this, with multiple DBs,or show what is wrong in my example?
TIA
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.