The absence of evident support of boolean fields in InterBase always surprised and interested the developers who used this server. And in any case these developers had to emulate the support of boolean fields.
Here it is necessary to mention that this emulation is possible only in client applications. It is so because the server itself is a determinate thing and any programmer cannot change it separately. That is why the question arises: what is the best way of emulation of boolean fields in applications?
In practice there are two usual solutions. You create either the first or second following domains:
CREATE DOMAIN T_BOOLEAN_INT
CHECK (VALUE IN (0,1))
CREATE DOMAIN T_BOOLEAN_CHAR
CHECK (VALUE IN ('T', 'F'))
Fields created with these domains are considered by the developer to be Boolean and with the help of visual components are shown to users. In particular if using TDBCheckBox you can show such properties as ValueChecked := 'T' and ValueUnchecked := 'F'. In this case the component will behave as if it deals with a real boolean field.
It is more difficult to allow users to edit some boolean fields in components of the TDBGrid type simply by ticking off instead of evident setting the 'F' property. Such way of programming will require non-trivial steps.
Of course you probably have thought a lot about the easiest way of solving this problem. If while executing the query Delphi automatically creates TBooleanField instances for necessary fields, the programmer's life will become more comfortable!
This possibility has already been realized in FIBPlus. For this in the database it is necessary to describe some domain like the above-mentioned 'T_BOOLEAN_INT'. That is the domain should necessarily be either of the smallint or integer type, which allows two possible values "0" and "not 0" and contains the word "boolean" in its name. Then you enable the corresponding option in TpFIBDataSet, for example:
pFIBDataSet1.PrepareOptions := pFIBDataSet1.PrepareOptions + [psUseBooleanField] (this can be done both in design-time and in run-time)
After this all the fields created with our special domain will be considered to be boolean and for them there will be automatically created TFIBBooleanField instances (it is a direct descendant of the TBooleanField class). That means that any visual component will consider the fields to be real boolean fields and this is very important for normal work!
|공지||이전게시판의 질문과답변 및 사용팁 메뉴얼관련 링크||admin||2008.01.23||5180|
|공지||넷서버 동영상 강좌||admin||2008.01.23||3915|
|28||패키지의 설치시 폴더의 설정||admin||2009.03.17||100523|
|27||XE2 이후 unit scope table||admin||2014.02.28||58386|
|26||윈도우서버 2008 R2에서의 닷넷의 문제||admin||2010.05.27||38977|
|»||FibPlus에서 Boolean 필드사용방법||admin||2008.03.18||11552|
|23||디버그컴포넌트(MaxExcept, EurekaLog...)의 사용시 유의사항||admin||2008.02.16||5328|
|22||넷서버 에러코드 및 설명||admin||2011.06.04||5064|
|21||넷서버의 설치 방법||admin||2008.01.24||4879|
|20||ch 3.메세지클라이언트의 제작||admin||2008.01.24||4529|
|19||ch 4. 비즈니스오브젝트의 작성-서버||admin||2008.01.24||4481|
|18||XP모드에서 TPanel의 Color 사용방법||admin||2008.05.23||4471|
|17||SQLite의 사용상의 주의||admin||2008.02.28||4383|
|16||ch 1. 간단한 BDE서버의 제작||admin||2008.01.24||4004|
|15||Synchronize 쉽게 사용하기||admin||2008.01.19||3962|
|14||Java 1.6버젼과 windows server 2008 r2 문제||admin||2011.12.13||3961|
|13||Open Source ODBC DBX Driver||admin||2008.02.05||3403|
|12||Ch7. 채팅클라이언트 프로그램의 제작||admin||2008.01.24||3180|