Hi, I have a table with combination primary key (tid, pid), I want to delete all records where tid = x how can I do this? Is there an easy way?
I have tried using a condition object but it failed:
$cond = GT::SQL::Condition->new('tid', '=', $tid);
doesn't work.
I have also tried select all pid where tid = $tid, looping through the results and calling delete on each iteration as follows:
$handle = $table->select( { tid => $tid }, ['pid'] );
while(my $row = $handle->fetchrow_hashref) {
$table->delete( { tid => $tid, pid => $row->{'pid'} } );
}
And it fails saying it cannot make a condition object. Besides this is not very efficient.
Does anyone have any ideas?
Thanks in advance, regards,
Tommy
I have tried using a condition object but it failed:
$cond = GT::SQL::Condition->new('tid', '=', $tid);
doesn't work.
I have also tried select all pid where tid = $tid, looping through the results and calling delete on each iteration as follows:
$handle = $table->select( { tid => $tid }, ['pid'] );
while(my $row = $handle->fetchrow_hashref) {
$table->delete( { tid => $tid, pid => $row->{'pid'} } );
}
And it fails saying it cannot make a condition object. Besides this is not very efficient.
Does anyone have any ideas?
Thanks in advance, regards,
Tommy