[prev] [thread] [next] [Date index for 2004/11/06]
Folks, I dont know if any of you are watching the dbi.users list, but I posted a problem there thats now irritating me quite a bit.. Basically I have a bunch of related tables (see below, yep, same stuff as the PersonCategory thing, only really they're bank transactions).. And I'm trying to get the corresponding category(s) of a transaction. Using DBI_TRACE shows that all its attempting to do is: SELECT category_id FROM transcategories WHERE transaction_id=? which works fine when I do it by hand, or using plain DBI, but via Class::DBI gets me: DBD::DB2::st execute failed: [IBM][CLI Driver] CLI0112E Error in assignment. SQLSTATE=22005 [for Statement "SELECT category_id FROM TransCategories WHERE transaction_id=? "] at /usr/lib/perl5/site_perl/5.8.4/DBIx/ContextualFetch.pm line 51. To which the db2 docs say: CLI0112E Error in assignment. Explanation: The data sent for a parameter or column was incompatible with the data type of the associated table column. User Response: Respecify the output binding through SQLBindCol or SQLGetData or the input binding through SQLSetParam or SQLBindParameter. .. So whats CDBI doing that plain DBI isnt? (This all works fine with SQLite, tested, but that didnt surprise me, as SQLite doesnt care about column types) Jess --------------------------------------------------------------------------------- simple test: use warnings; use Bank::Data; use Data::Dumper; my $trans = Bank::Transaction->retrieve(271); print Dumper($trans); print $trans->bank_date(), "\n"; print Dumper($trans); print $trans->category(), "\n"; print Dumper($trans->category()); dies on the "print $trans->category()" line. --------------------------------------------------------------------------------- package Bank::TransCat; use base 'Bank::Data'; use Data::Dumper; Bank::TransCat->table('TransCategories'); Bank::TransCat->columns(All => 'transaction_id', 'category_id'); Bank::TransCat->has_a(transaction_id => 'Bank::Transaction'); Bank::TransCat->has_a(category_id => 'Bank::Category' ); sub accessor_name { my ($class, $column) = @_; $column =~ s/_id//; return $column; } package Bank::Category; use base 'Bank::Data'; Bank::Category->table('Categories'); # Bank::Category->columns(All => 'category_id', 'name', 'essential'); Bank::Category->columns(All => 'category_id', 'name'); Bank::Category->has_many(transactions => [ 'Bank::TransCat' => 'transaction_id' ] ); sub accessor_name { my ($class, $column) = @_; $column =~ s/_id//; return $column; } package Bank::Transaction; use base 'Bank::Data'; Bank::Transaction->table('Transactions'); Bank::Transaction->columns(All => 'transaction_id', 'bank_date', 'amount', 'type_id', 'effective_date', 'thirdparty_name', 'bank_balance'); Bank::Transaction->has_a(type_id => 'Bank::T_Types'); Bank::Transaction->has_many(comments => [ 'Bank::Comment' => 'comment_id' ]); Bank::Transaction->has_many(category => [ 'Bank::TransCat' => 'category' ]); sub accessor_name { my ($class, $column) = @_; $column =~ s/_id//; return $column; } -- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Strange DB2 errors..
|
Generated at 11:34 on 01 Dec 2004 by mariachi v0.52