Email Purposes

Former Member
Former Member $organization

Has anyone written code to insert a value into the mail_purpose field in T_EADDRESS without overwriting the existing values in that field? This field has 10 positions and I want to insert a value into one of the positions without erasing what's there. So the SET command won't work. I'm thinking there is a way to identify the position of the value you want to enter.

Parents
  • Hi Gloria,

    Here is a simple function that adds and removes a single single purpose.  It takes the current purposes string, the purpose to add or remove, and a mode parameter to tell it whether to add or remove.  It returns the updated purposes string. 

    Jon

  • Former Member
    Former Member $organization in reply to Jon Ballinger

    I think you're my hero Jon!

    So I would need to include this function in a procedure, right (excuse my ignorance with functions)? What is the mode parameter - 1=add, 2=remove?

    Then I can run this for a list?

    I found that this works:

    UPDATE t_eaddress
    SET Mail_Purposes=Mail_Purposes+'3'
    WHERE customer_no = 26824
     AND CHARINDEX('3',Mail_Purposes)=0

     

    But it doesn't put the purposes in the right order.

Reply
  • Former Member
    Former Member $organization in reply to Jon Ballinger

    I think you're my hero Jon!

    So I would need to include this function in a procedure, right (excuse my ignorance with functions)? What is the mode parameter - 1=add, 2=remove?

    Then I can run this for a list?

    I found that this works:

    UPDATE t_eaddress
    SET Mail_Purposes=Mail_Purposes+'3'
    WHERE customer_no = 26824
     AND CHARINDEX('3',Mail_Purposes)=0

     

    But it doesn't put the purposes in the right order.

Children