Primary Key Not working?

SUGGESTED

So I have this table that has only one index.  That index has four fields (composite key).  From what I've read on the sage knowledgebase, the first index defined inside a table is THE Primary Key.  However, Somehow I am able to write data to this table, with duplicate keys.  I understand databases and primary keys.  What I don't understand is how Sage is actually dealing with them.  

How do I get primary keys to work?  Or is there even a way to define a primary key on a table? I tested this on another server. At first it was promising, the primary key prevented duplicates. I wanted to test if the index defined on the table actually did anything so I changed it, and sure enough I was able to add records that I couldn't before (because before, they violated the primary key).  When I tried to change the Primary Key back to its original form I even got a beautiful message telling me there were duplicate records. So i deleted those records and was able to change the primary key to its original state. However, now I'm getting duplicate records violating the key! 

What's going on? I'm not observing any consistent behavior. If you change the index to a table, is a table validation not enough? What else do you have to do?

Because at this point I'm about to write code that will validate the key before writing to the table. Which is not good practice but apparently the constraints configured aren't functioning properly.

Parents
  • 0

    Ok so like minutes after I posted this I attempted a forced validation and that worked. Not sure why, couldn't find anything about primary keys/index and forced validation on any knowledge base but would love to.  

    So I guess change this question to What is a forced validation? What are the risks? Am I going to rip open a hole in my computers space time continuum?

Reply
  • 0

    Ok so like minutes after I posted this I attempted a forced validation and that worked. Not sure why, couldn't find anything about primary keys/index and forced validation on any knowledge base but would love to.  

    So I guess change this question to What is a forced validation? What are the risks? Am I going to rip open a hole in my computers space time continuum?

Children
  • 0 in reply to Breedlove
    SUGGESTED

    Hi,

    Here is how the Online help center describes the table validation and the forced validation:

    This function is used to create or to update the table in the database from the dictionary. If the table does not exist, it is created empty of data. If it exists, the table structure is updated conforming to the new description given in the dictionary (the new fields are added, the deleted fields are removed, the fields whose structure or dimension has changed are recopied: the records are of course conserved in the table). It is possible to force the validation: a complete revalidation of the data and indexes. If this option is not specified and if the table structure is not changed, only the indexes will be recreated.

    I hope this helps.