September 6, 2010 at 6:19 am
Dear Experts,
I really struggle with this
I have one table with 6 columns
Id , T1_flg,T2_flg,T3_flg,T4_flg,T5_flg
1001 ,1 ,0 ,0 ,1 ,0
1002 ,0 ,1 ,0 ,0 ,0
I want to check with cross if already one slab is exits i wont allow to insert,
If my insert values is
1003 ,0,0,1,0,1 should allow to insert
if my input is
1003 ,1,0,0,0,0 shoul not allow, because the T1_flg, is already active with previous slab.. please help me to overcome this problem
September 6, 2010 at 8:05 am
I would change the design of the table:
Unpivot the data, reduce it to have only values other than Zero and add a unique constraint on Flg_type.
You'd basically have a table as follows
ID Flg_type
1001 T1
1001 T4
1002 T2
With the constraint as mentioned you can add
1003 T3
1003 T5
But not
1003 T1
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply