0

I have in DB2 a table with a VARCHAR column containing a probability distribution, such as "0.3, 0.1, 0.3, 0.2, 0.1".

I'm wondering if I could create a check constraint for this column in order to check that the sum of the probabilities is indeed 1.

I've been through DB2 documentation and several tutorials, but I couldn't find anything related to this issue.

user998692
  • 5,172
  • 7
  • 40
  • 63
  • 1
    If you stored probability values in separate columns, that would be simple. As it stands you will need to create a user-defined function to parse the string into numbers and computing their sum. You can then reference that function in the check constraint. – mustaccio Apr 02 '14 at 20:14
  • This table was created like this, it was not my choice... – user998692 Apr 02 '14 at 21:19

0 Answers0