tags:

views:

41

answers:

1

Hi,

I have a table which has only one number field: [ value NUMBER(12.0) ]

I would like to store these two types of non negative numbers.

Type A : ( a list of non negative numbers )

Type B : ( another list of non negative numbers )

I have just this one table. Without making any DML changes, is it possible for me to store both types of numbers, with some distinction..

I thought of using sign to differentiate , but it will fail in case of 0..

Thanks, Trinity

+3  A: 

You can store either a or ~b. This fixes the problem with zero because ~0 is -1.

The expression ~b means the bitwise not of b and is equivalent to -b - 1.

However I would strongly advise you to change the schema if it is at all possible. This hack could turn out to be a maintenance nightmare for whoever has to take over the system after you.

Mark Byers
Ya, i do understand that such a hack will be highly undesirable.. Was simple curious to know if i can get this done with the current schema.. Thanks for the idea!
trinity