Subject | Re: [firebird-support] Simulating Boolean field |
---|---|
Author | Ivan Prenosil |
Post date | 2005-09-02T11:54:53Z |
> today morning I was thinking about the Boolean simulation in FB 1.5 . I'veFor NULL you would have to use different query
> found two solutions.
> 1: char(1) with 'T' and 'F' and some validation (check, trigger)
> 2: char(1) with X (as Yes/True) and NULL (No/False)
>
> What's better (performance, management, ...)?
> How you're working with Boolean?
(i.e. it can cause problems with prepared statements)
Compare
WHERE myfield='T'
WHERE myfield='F'
and
WHERE myfield='X'
WHERE myfield IS NULL
Another alternative is SMALLINT, which has the advantage that
- it is language independent (no variants like T/F, Y/N, A/N, etc)
- it is always sorted correctly (0<1)
- if true boolean will be implemented, it is more likely to be stored as number (I think)
Ivan