Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2003

    Unanswered: Enforcing Uniqueness


    I was wondering if it is possible to enforce uniqueness of a column, which is dependant upon another column. How can you check that a record is unique on updates/inserts where the value depends upon another column on that table?


    record A has values
    column 1 : ABC
    column 2 : 123

    record B has values
    column 1: XYZ
    column 2: 123

    record C has values
    column 1: ABC
    column 2: 234

    If I tried to insert ABC , 234 it would give an error, but if I inserted/updated XYZ, 234 it would succeed. I have thought about using a trigger but have not had much experience in writing them so am having problems, in particular with including column '1' into the equation.

  2. #2
    Join Date
    Jul 2003
    Penang, Malaysia
    correct me if I understood u'r question wrongly

    Wouldn't putting a primarky key ( so it becomes a composite) constraint on both columns solve u'r problem???
    Patrick Chua
    LBMS ( Learn By My Self) NPQ ( No paper Qualification )

  3. #3
    Join Date
    Dec 2003
    Yeah you are right, works fine now. I don't know why I never thought of that before...

    Thanks for the idea

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts