create table hubba (id int, a varchar2(20), b varchar2(20));
####
package SMU::Schema;
use base qw(DBIx::Class::Schema);
__PACKAGE__->load_namespaces;
1;
####
package SMU::Schema::Result::Hubba;
use DBIx::Class;
use Moose;
extends 'DBIx::Class';
has 'id' => ( is => "ro", isa => "Int");
has 'a' => ( is => "rw", isa => "Str");
has 'b' => ( is => "rw", isa => "Str");
sub dump {
my($this)=@_;
return $this->id . " - " . $this->a . " - " . $this->b;
}
__PACKAGE__->load_components('Core');
__PACKAGE__->table('hubba');
__PACKAGE__->add_columns(
id => { data_type => 'integer', size => 16 },
a => { data_type => 'varchar', size => 20 },
b => { data_type => 'varchar', size => 20 },
);
__PACKAGE__->set_primary_key('id');
1;
####
my $schema = SMU::Schema->connect("dbi:Oracle:SMU", "user", "pw") or die $!;
# find row with id=1 and return as object
my $h1 = $schema->resultset('Hubba')->find(1);
# persist new object
$schema->resultset('Hubba')->create( {
id => 2,
a => "blah",
b => "blubb",
});