0

I have a CCK field with a data type 'text', that I want to change to 'decimal'.

I have used a hook_update_N and db_change_field in order to do this.

Here is an example how I tried to do it:

function ptm_foo_update_6005() {
  db_change_field(
    $ret,
    'content_type_',
    'field_foo_value',
    'field_foo_value',
    array(
      'type' => 'decimal(10,2)',
      'description' => 'Foo'
    )
  ); 
}

But when I execute the update, it gives me the following error message:

User warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax

  • where you apply this code? means in template.php? – monymirza Nov 19 '12 at 14:38
  • In a <mymodulename>.module file. – rfc1484 Nov 19 '12 at 15:03
  • using mysql or pgsql ?? – monymirza Nov 19 '12 at 16:10
  • Using mysql, I linked the pgsql page of the documentation because the mysql one it's not complete. – rfc1484 Nov 20 '12 at 8:05
1

Based on the comments on your question, I certainly hope you're doing this in a .install file and not a .module file.

The $ret variable is expected to be a reference, so you'll need to declare it before hand.

$ret = array();
db_change_field($ret ...);

Is your table name really content_type_?

And you may want to look at this and stick in a couple dsm() calls to see what the db_change_field() function is actually passing to MySQL and then you could trouble shoot the query directly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.