[Dbix-class] How to alter table via DBIC?
Chris Cole
chris at compbio.dundee.ac.uk
Tue May 11 20:01:00 GMT 2010
On Tue, 11 May 2010 14:23:50 +0100, Chris Cole
<chris at compbio.dundee.ac.uk> wrote:
> On Tue, 11 May 2010 14:02:38 +0100, Rob Kinyon <rob.kinyon at gmail.com>
> wrote:
>
>> On Tue, May 11, 2010 at 08:52, Chris Cole <chris at compbio.dundee.ac.uk>
>> wrote:
>>> Hi,
>>>
>>> I have a partitioned Oracle table that I want add data to, but it
>>> needs to
>>> be done on named partitions. Before I can insert the data I need to
>>> create a
>>> new partition. Manually, this is done via an ALTER TABLE statement,
>>> but I
>>> can't see anywhere on how to do this from within DBIC. Is this
>>> possible, at
>>> all?
>>
>> I hope someone will give you a better answer than this, but you should
>> know about one of the "escape hatches".
>>
>> $schema->storage->dbh_do( sub {
>> my $dbh = shift;
>>
>> # At this point, you have the raw DBI $dbh that you would get from
>> DBI->connect
>> # So, you can literally do whatever you want here.
>> });
>>
>> HTH
>> Rob
>
> Ah, that's useful to know.
> Thanks,
Except it doesn't work :(
This code:
$schema->storage->dbh_do( sub {
my $dbh = shift;
$dbh->do("ALTER TABLE ngs_reads MODIFY PARTITION $partition ADD
VALUES($id)") or die "ERROR - error unable to add new mapping experiment
to '$partition' partition on NGS_READS table\n";
$dbh->do("ALTER TABLE ngs_mappings MODIFY PARTITION $partition ADD
VALUES($id)") or die "ERROR - error unable to add new mapping experiment
to '$partition' partition on NGS_MAPPINGS table\n";
});
Gives this error:
Warning - transaction failed and rolling back:
DBIx::Class::Schema::txn_do(): Can't locate object method "do" via package
"DBIx::Class::Storage::DBI::Oracle::Generic" at
/homes/ccole/projects/workspace/NGSdb/load_drs_data.pl line 176.
Any ideas why $dbh-do() is failing?
More information about the DBIx-Class
mailing list