Search code examples
databasedb2websphere-commerce

How do I create a new customer segment in Websphere Commerce using only DB2 database queries?


How can I add a new customer segment using only the database? I know how to create customer segments in CMC, but I'm looking to automate the process of adding, say, hundreds of user segments by writing a script to do it for me. However, I can't find any information on how to create a new customer segment using only DB2 database queries.

Is there a way to create a new customer segment using nothing but DB2 database queries?


Solution

  • I would not recommend that you use SQL directly to create customer segments, as this makes generation of primary keys and updates of the KEYS table your responsibility. And once you take that on, Murphy's Law states that you'll get something wrong.

    Your question asks how to create "hundreds of user segments". However, I'm not sure if that's what you meant, or if you meant that you had hundreds of users to add to existing segments.

    If you're talking about loading hundreds of users, then I'd refer you to this article in the Knowledge Center that explains how you can use the MemberGroupMemberMediator to load segments from e-mail addresses.

    If you truly mean to create segments by data load, I'd refer you to this Knowledge Center article that shows how to create member groups. A customer segment is a member group with a particular usage type.

    For reference, these are the tables involved:

    • MBRGRP: The base group (segment) definintion
    • MBRGRPCOND: This is used to define the condition if it is a rule-based segment (e.g. "all shoppers over the age of 25")
    • MBRGRPDESC: The NLS description (name, etc) of the segment
    • MBRGRPMBR: For manually defined segments, this defines the members (relationship to MEMBER table)
    • MBRGRPTYPE: The type of the member group (e.g. "CustomerGroup")
    • MBRGRPUSG: The usage code for the member group (e.g. "GeneralPurpose")