CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Manual SQL script to update preferred communication method
Pages: [1]

Author Topic: Manual SQL script to update preferred communication method  (Read 964 times)

Michael McAndrew

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1274
  • Karma: 55
    • Third Sector Design
  • CiviCRM version: various
  • CMS version: Nearly always Drupal
  • MySQL version: 5.5
  • PHP version: 5.3
Manual SQL script to update preferred communication method
February 26, 2009, 09:14:48 am
Hi,

I have a MySQL script that I am running to run to update preferred communication methods for my contacts.  I understand that I have to insert it using CRM_Core_DAO::VALUE_SEPARATOR but am unsure how I can represent this in an UPDATE statement.  Is there a way?

I tried
Code: [Select]
UPDATE civicrm_contact SET preferred_communication_method=3 WHERE external_identifier='p-5677';but that didn't work - neither did
Code: [Select]
UPDATE civicrm_contact SET preferred_communication_method=CONCAT(CHAR(000),2,CHAR(000)) WHERE external_identifier='p-5677';
Anyone want to help me out?

Thanks!
Service providers: Grow your business, build your reputation and support CiviCRM. Become a partner today

Michael McAndrew

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1274
  • Karma: 55
    • Third Sector Design
  • CiviCRM version: various
  • CMS version: Nearly always Drupal
  • MySQL version: 5.5
  • PHP version: 5.3
Re: Manual SQL script to update preferred communication method
February 26, 2009, 09:48:20 am
So near yet so far - worked it out in the end.  CRM_Core_DAO::VALUE_SEPARATOR is equivilant to CHAR(1) so

Code: [Select]
UPDATE civicrm_contact SET preferred_communication_method=CONCAT(CHAR(1),2,CHAR(1)) WHERE external_identifier='p-5677';
does the job.
Service providers: Grow your business, build your reputation and support CiviCRM. Become a partner today

alfred_nutile

  • Ask me questions
  • ****
  • Posts: 464
  • Karma: 14
    • River Valley Tech Collective
Re: Manual SQL script to update preferred communication method
June 15, 2009, 04:09:07 pm
This worked for me....
My update was to add the ^A before and after the data this was so I could convert a single select custom data field into a multi.
<code>
 UPDATE `civicrm_value_motivation__contribution__2` SET motivation_tag_4 = concat( '', `motivation_tag_4` , '' ) 
</code>
The ' <--apostrophe is key around the left and right field else mysql gives the strangest error.
I also edit the civicrm_custom_field in question and changed the default_value to   (2 of them)
Then set the single select menu to double in the same record.
After that TRUNCATE TABLE `civicrm_cache`  was key to make it all work.

Thanks Lobo of course since this was all you.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Manual SQL script to update preferred communication method

This forum was archived on 2017-11-26.