#------------------------------------------------------------
# Copyright (C) 2006 RoyaltyShare, Inc.   All Rights Reserved
# $Id$
#------------------------------------------------------------
package RPS::DB::Item::MechanicalStatementCell;
use strict;
use warnings;
use lib '/app/tools/common/lib';
use Common::Assert;
use Common::DB::Item;
use Common::DB::ItemCollection;
use base 'Common::DB::Item';


use constant kTable => 'mechanical_statement_cell';
use constant kDB => Common::DB::Item::kClientDB();


sub DeleteByMechanicalStatementID
{
    my ($class, $id) = @_;

	my $sql = "DELETE from ".kTable." WHERE mechanical_statement_row_id IN (SELECT mechanical_statement_row_id FROM mechanical_statement_row WHERE mechanical_statement_id = $id)";
	my $dbo = Common::RSApp::GetClientDB();
    $dbo->DoCmd($sql);
}

sub UpdateMechanicalStatementCellLink
{
    my ($class, $oldLink, $newLink, $statementID) = @_;

	my $sql = "UPDATE ".kTable." SET link_value = '" . $newLink . "' WHERE mechanical_statement_row_id IN (SELECT mechanical_statement_row_id FROM mechanical_statement_row WHERE mechanical_statement_id = $statementID)";
	$sql .= " AND link_value = '" . $oldLink . "'";
	my $dbo = Common::RSApp::GetClientDB();
    $dbo->DoCmd($sql);
}

1;
