As you know Firebird doesn't have a BOOLEAN field type.
Their "solution" is to create a domain of type CHAR, with length 1, with values "Y" or "N".
But this only causes me problems in Delphi.
1) Does TZTable have a nice way of solving this problem so that the field is read as BOOLEAN?
2) If you're good with Firebird and Delphi, please let me know what else I must do in delphi to be able to treat these fields as BOOLEAN?
Boolean Fields (as CHAR fields in Firebird)
Moderators: gto, cipto_kh, EgonHugeist
Hi Seawolf. Thanks for your answer. Yes I already have changed it to length 5 and replaced all the 'Y' with 'True' and all the 'N' with 'False.
This worked fine (and took me hours and hours to do) until I realised that one section of my application now doesn't work because I don't have proper boolean fields.
I have already spent about 4 hours trying to fix it. The easiest solution would be if it could be read as a BOOLEAN field in Delphi - but instead I have to search through probably a few thousand lines of codes changing away from Boolean to String.
What a @#R$#@ing nightmare!
This worked fine (and took me hours and hours to do) until I realised that one section of my application now doesn't work because I don't have proper boolean fields.
I have already spent about 4 hours trying to fix it. The easiest solution would be if it could be read as a BOOLEAN field in Delphi - but instead I have to search through probably a few thousand lines of codes changing away from Boolean to String.
What a @#R$#@ing nightmare!
Boolean Field SOLVED - The best Way to be compatible
Im having the same problem.
My grid have boolean editor and doesnt work cause is a smallint or a char(1) or (5) field ... (as we like to ).
So there is another way,
Zeos Support for this ?????
How can we request this to zeos team ????
Can be done in fb the next :
CREATE DOMAIN BOOLEAN
AS SMALLINT
CHECK(Value is null or value on (0,1));
IMPORTANT GADGET
IMPORTANT GADGET
IMPORTANT GADGET
So if zeos got the BOOLEAN identifier check if is a number or text ( if text the size 1 or 5)
TbooleanField is a word (B) keep on the record WORDBOOL.
So the record is keep on memory (zeos components control record structure in memory) so they can just check for the DOMAIN name ( filed type) and translate when send to server.
If zeos team develop this, not dificult ( built in on components )
This Just worked fine.
IMPORTANT GADGET
IMPORTANT GADGET
IMPORTANT GADGET PLEASE ZEOS TEAM
Anyway i can do it with some extra code, ill post it when is friendly .. but is much better be Zeos Builtin.
My grid have boolean editor and doesnt work cause is a smallint or a char(1) or (5) field ... (as we like to ).
So there is another way,
Zeos Support for this ?????
How can we request this to zeos team ????
Can be done in fb the next :
CREATE DOMAIN BOOLEAN
AS SMALLINT
CHECK(Value is null or value on (0,1));
IMPORTANT GADGET
IMPORTANT GADGET
IMPORTANT GADGET
So if zeos got the BOOLEAN identifier check if is a number or text ( if text the size 1 or 5)
TbooleanField is a word (B) keep on the record WORDBOOL.
So the record is keep on memory (zeos components control record structure in memory) so they can just check for the DOMAIN name ( filed type) and translate when send to server.
If zeos team develop this, not dificult ( built in on components )
This Just worked fine.
IMPORTANT GADGET
IMPORTANT GADGET
IMPORTANT GADGET PLEASE ZEOS TEAM
Anyway i can do it with some extra code, ill post it when is friendly .. but is much better be Zeos Builtin.
where's the code ..
Best Way bye now to solve this leaving your code intact.
This works just perfect.
I was forced to sniff around code to solve this so i did this :
We have on delphi field this code :
- - - - TStringField.GetASBoolean : Boolean;
var
s : string :
begin
s := getasstring;
Result := (length(s)>0)and(S[1] in ['T','t','Y','y']);
end;
This means that if the field is a text at least from 1 char and the 1st char of string is ( T,t,Y,y) as boolean is true Other char is FALSE
USE THEN : VARCHAR(1) or what u want VARCHAR(5) for True or False or Yes or No word but the best is T F ( as SetasBoolean do).
(T or F char will be automatic posted by setasboolean function).
Create this type on your unit ( must be in the unit u ll use setdatatype() procedure ..... )
Type
TMyBoolType = class(TField)
end;
procedure justchangeType(dataset:TDataset);
var
aa: integer;
begin
For aa := 0 to dataset.fields,count - 1 do
if (dataset.fields[aa].datatype = ftString)and(dataset.fields[aa].size=1) then
begin
TMyBoolType(dataset.fields[aa]).setdatatype(ftBoolean);
//this will trick the field type dont do with other field type (only TStringField) or ull get
" Access Error Cant be read as Boolean"
end;
end;
OnDataModuleCreate Do:
begin
justchangeType(MyTable1);
justchangeType(MyTable2);
justchangeType(MyTable3);
end;
Best Way bye now to solve this without change a dbgrid with boolean editor and "works fine" .
Can read and write values withou a problem ( on the oncalc u can only read not write asboolean and with this u can keep all your code intact without any other changes).
[align=justify]/* BEWARE IN CASE U USE A STRING OF VARCHAR BUT NOT FOR THE BOOLEAN (THE BEST IS USE VARCHAR(1) AS DEMO TO GARANTIE YOU WILL NOT HAVE PROBLEMS THEN) */
SO ILL NOT TAKE RESPONSABILITIES FOR ANY KIND OF ERRORS OR DAMAGE ETC ,USE IT AT YOUR OWN RISK.
[/align]
So what i did in SQL :
CREATE DOMAIN BOOLEAN
AS VARCHAR(1)
CHECK(value is null or value in ('T','F'));
CREATE TABLE CoolStuff(
cs_id INTEGER,
cs_dsc VARCHAR(250),
cs_iscool BOOLEAN,
cs_tosell BOOLEAN,
primary key (cs_id)
);
Hope This will Solve problem to all of you , did solve greatly to me.
I was forced to sniff around code to solve this so i did this :
We have on delphi field this code :
- - - - TStringField.GetASBoolean : Boolean;
var
s : string :
begin
s := getasstring;
Result := (length(s)>0)and(S[1] in ['T','t','Y','y']);
end;
This means that if the field is a text at least from 1 char and the 1st char of string is ( T,t,Y,y) as boolean is true Other char is FALSE
USE THEN : VARCHAR(1) or what u want VARCHAR(5) for True or False or Yes or No word but the best is T F ( as SetasBoolean do).
(T or F char will be automatic posted by setasboolean function).
Create this type on your unit ( must be in the unit u ll use setdatatype() procedure ..... )
Type
TMyBoolType = class(TField)
end;
procedure justchangeType(dataset:TDataset);
var
aa: integer;
begin
For aa := 0 to dataset.fields,count - 1 do
if (dataset.fields[aa].datatype = ftString)and(dataset.fields[aa].size=1) then
begin
TMyBoolType(dataset.fields[aa]).setdatatype(ftBoolean);
//this will trick the field type dont do with other field type (only TStringField) or ull get
" Access Error Cant be read as Boolean"
end;
end;
OnDataModuleCreate Do:
begin
justchangeType(MyTable1);
justchangeType(MyTable2);
justchangeType(MyTable3);
end;
Best Way bye now to solve this without change a dbgrid with boolean editor and "works fine" .
Can read and write values withou a problem ( on the oncalc u can only read not write asboolean and with this u can keep all your code intact without any other changes).
[align=justify]/* BEWARE IN CASE U USE A STRING OF VARCHAR BUT NOT FOR THE BOOLEAN (THE BEST IS USE VARCHAR(1) AS DEMO TO GARANTIE YOU WILL NOT HAVE PROBLEMS THEN) */
SO ILL NOT TAKE RESPONSABILITIES FOR ANY KIND OF ERRORS OR DAMAGE ETC ,USE IT AT YOUR OWN RISK.
[/align]
So what i did in SQL :
CREATE DOMAIN BOOLEAN
AS VARCHAR(1)
CHECK(value is null or value in ('T','F'));
CREATE TABLE CoolStuff(
cs_id INTEGER,
cs_dsc VARCHAR(250),
cs_iscool BOOLEAN,
cs_tosell BOOLEAN,
primary key (cs_id)
);
Hope This will Solve problem to all of you , did solve greatly to me.
where's the code ..
-
- Junior Boarder
- Posts: 30
- Joined: 12.08.2011, 12:42
- Location: Brazil
- Contact:
it was code in FB 3.0 as you can see at http://asfernandes.blogspot.com.br/