in reply to Re^4: [CDBI] avoiding set_sql() redefinitions
in thread [CDBI] avoiding set_sql() redefinitions

One thing that I do is put the reporting queries for my tables into their respective CDBI classes for organizational purposes. It helps keep all the related queries together. Then I make a method in the class that runs the query and returns the result. Here's a small example:
# in package DB::Contribition __PACKAGE__->set_sql(average_dollars => <<'END_SQL' ); SELECT AVG(amount) FROM contribution END_SQL sub average_dollars { my $class = shift; my $sth = $class->sql_average_dollars(); $sth->execute(); return $sth->select_val() || 0; }