메뉴 건너뛰기

넷서버 사용 팁/강좌

FibPlus에서 Boolean 필드사용방법

admin 2008.03.18 08:31 조회 수 : 11436

Counter: 884
Published: 2007-01-29 18:53:12

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
AS SMALLINT
DEFAULT 0
NOT NULL
CHECK (VALUE IN (0,1))

Or

CREATE DOMAIN T_BOOLEAN_CHAR
AS CHAR(1)
DEFAULT 'F'
NOT NULL
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 4443
공지 넷서버 동영상 강좌 admin 2008.01.23 3852
공지 넷서버 소개문서 넷서버 2008.01.19 5039
31 midaslib를 추가해 주십시오 admin 2015.08.19 215
30 XE2 이후 unit scope table admin 2014.02.28 1657
29 Java 1.6버젼과 windows server 2008 r2 문제 admin 2011.12.13 3657
28 넷서버 에러코드 및 설명 admin 2011.06.04 4752
27 윈도우서버 2008 R2에서의 닷넷의 문제 admin 2010.05.27 16496
26 패키지의 설치시 폴더의 설정 admin 2009.03.17 5735
25 XP모드에서 TPanel의 Color 사용방법 admin 2008.05.23 4414
» FibPlus에서 Boolean 필드사용방법 admin 2008.03.18 11436
23 SQLite의 사용상의 주의 admin 2008.02.28 4307
22 디버그컴포넌트(MaxExcept, EurekaLog...)의 사용시 유의사항 admin 2008.02.16 5042
21 Open Source ODBC DBX Driver admin 2008.02.05 3311
20 넷서버의 설치 방법 admin 2008.01.24 4773
19 [동영상] 넷서버 클라이언트 프로그램의 제작 admin 2008.01.24 2974
18 [동영상] 넷서버 서버의 제작 admin 2008.01.24 2650
17 Ch7. 채팅클라이언트 프로그램의 제작 admin 2008.01.24 3107
16 Ch6. 채팅서버 프로그램의 제작 admin 2008.01.24 3060
15 ch 5. 비즈니스오브젝트를 클라이언트에서 사용하기 admin 2008.01.24 2651
14 ch 4. 비즈니스오브젝트의 작성-서버 admin 2008.01.24 4397
13 ch 3.메세지클라이언트의 제작 admin 2008.01.24 4471
12 ch 2. 간단한 클라이언트프로그램의 제작 admin 2008.01.24 2890
위로