finally found newbee error,
this is what i do:
purchases>>Delete Page>> Action Before Delete:
$db->where('id',$rec_id);
$products_id = $db->getValue('purchases', 'product_id');
purchases>>Delete Page>>Action After Delete:
//$count_qty = $db->rawQuery("SELECT SUM(received_number) FROM purchases WHERE product_id=$products_id");
//execute SQL statement and return the result
//$params = array($products_id);
//$count_qty = $db->rawQuery("SELECT SUM(received_number) FROM purchases WHERE product_id=$products_id", $params);
$sql = "UPDATE products SET products.received_inventory = (SELECT SUM(received_number) FROM purchases WHERE product_id=$products_id) WHERE id = $products_id ";
$db->rawQuery($sql);
i originally want to use $count_qty instead a nested query, but it was fail to me.
please suggest with better sql query.
thank you