NAME Class::DBI::View - Virtual table for Class::DBI SYNOPSIS package CD::Music::SalesRanking; use base qw(CD::DBI); # your Class::DBI base class use Class::DBI::View qw(TemporaryTable); __PACKAGE__->columns(All => qw(id count)); __PACKAGE__->setup_view(<setup_view($sql [, %opt ]); Setups virtual VIEW for $class. $sql should be a raw SQL statement to build the VIEW. %opt can be any of these: cache_for_session Caches temporary table per database connection. Only valid for "TemporaryTable" implementation. # creates tmp table once per session __PACKAGE__->setup_view($sql, cache_for_session => 1); TIPS AND TRAPS You know Class::DBI's "retrieve" method wants value for primary key. What if your view doesn't have primary column? Quick solution would be making primary column by combining some columns like: __PACKAGE__->columns(All => qw(id acc_id orgname sub_id productname)); __PACKAGE__->setup_view( < with feedbacks from: Dominic Mitchell Edom@semantico.comE Tim Bunce ETim.bunce@pobox.comE This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. SEE ALSO the Class::DBI manpage