Hi
I have say 10 items in a record and if in any one row the value in U_Item = 'MT' then all 10 items must hace "MT" in u_item else it should not allow to save record.
Thanks
Hi
I have say 10 items in a record and if in any one row the value in U_Item = 'MT' then all 10 items must hace "MT" in u_item else it should not allow to save record.
Thanks
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Eliana BlakeRank #1,595 · 993 reputationPosted Mar 16, 2025, 2:11 AM EDT
It sounds like you are looking to enforce a validation rule in a record where if one item has a certain value, all items must have the same value. This can be achieved through validation logic in your application or database.
For example, if you are working with a database system like SQL, you can define a validation trigger or constraint that checks if the condition is met before allowing the record to be saved. Here is a simple pseudo-code representation of such a validation logic:
CREATE TRIGGER CheckItems BEFORE INSERT ON YourTable FOR EACH ROW BEGIN IF NEW.U_Item = 'MT' THEN IF NEW.Item1 != 'MT' OR NEW.Item2 != 'MT' OR ... OR NEW.Item10 != 'MT' THEN SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'All items must have "MT" when U_Item is "MT"'; END IF; END IF; END;In this trigger, before inserting a new record into `YourTable`, it checks if `U_Item` is 'MT'. If it is, then it verifies that all Item fields (Item1 through Item10) also have the value 'MT'. If any Item field does not have 'MT', the trigger raises an error preventing the record from being saved.
This is just a simplified example, and the actual implementation may vary based on your specific database system and requirements. If you are working in a different environment or with specific software, let me know so I can provide more targeted guidance.