Skip to main content

SQL

Change Drupal 7 decimal field scale or precision

Submitted by system on

We wanted to change the MRP field 'field_per_item_cost' from DECIMAL (12,2) to DECIMAL (12,3).

 The following SQL Query will do the trick:  

ALTER TABLE field_data_field_per_item_cost MODIFY field_per_item_cost_value DECIMAL(12,3); 

ALTER TABLE field_revision_field_per_item_cost MODIFY field_per_item_cost_value DECIMAL(12,3); 

UPDATE field_config SET data = REPLACE(data, '"scale";s:1:"2";', '"scale";s:1:"3";') WHERE field_name = 'field_per_item_cost'; 

Extract Result Data From Drupal View

Submitted by amitsedai on
The code to do the trick is provided below: <?php
$view = views_get_view('view_name');
$view->init();
$view->set_display('default'); // or display id like page_1, block_1
//$view->set_arguments(array('arg_data'));
//$view->set_arguments(array(arg(0),'arg_data2')); // 2nd Argument
$view->pre_execute();
$view->execute();
//print_r($view->result);
drupal_set_message("Field data value: ".$view->result[0]->node_data_field_as_it_appears_in_views_query_sql);
?>

Update for Drupal 7: <?php