TZTable establish a dbText type field with empty and non-NUL
Posted: 08.05.2013, 09:36
Hi,
took several days to a problem that has naked eye should not be hard to fix, but here I am not knowing what else to turn. Such a problem has arisen with the I component ZEOS TZTable package.
I'm programming with Delphi 2010 and using version 7.0.3 stable ZEOS
It is assigned an empty value, not NULL, a specific type field DBMemo. But to assign the empty string, the component sets this field to the value NULL in the database (MySQL). It is not a problem of the structure of the table, as if the insertion is done by SQL code works perfectly.
Here I leave the function I use to assign this field
This is the function in DELPHI:
[php]
procedure SetValues(tipo:integer; valor:String='');
begin
With zTable1 do
try
if not (State in [DsEdit, DsInsert]) then
edit;
case tipo of
//Set value to NULL
0:fieldByname(fieldName).Clear;
//Set value to EMPTY
1:fieldByname(fieldName).AsString:='';
else
//Set value to TEXT
fieldByname(fieldName).AsString:=Valor;
end;
finally
try
post;
except
On e:Exception do begin
MessageDlg(E.Message, mtError, [mbOK], 0);
cancel;
end;
end;
end;
end;
[/php]
the function fails when type = 1, I tried putting the character 0 (# 0) instead of double quotes, and in that case no longer returns a NULL value, but that option does not help, because the length of the field and not is 0, otherwise 1.
As a last alternative I upgraded to the latest version of ZEOS and continuous components with the same problem.
Indicate that this same process is working without any problem with ADO components into a MSSQL database
Thanks for your help and greet all
took several days to a problem that has naked eye should not be hard to fix, but here I am not knowing what else to turn. Such a problem has arisen with the I component ZEOS TZTable package.
I'm programming with Delphi 2010 and using version 7.0.3 stable ZEOS
It is assigned an empty value, not NULL, a specific type field DBMemo. But to assign the empty string, the component sets this field to the value NULL in the database (MySQL). It is not a problem of the structure of the table, as if the insertion is done by SQL code works perfectly.
Here I leave the function I use to assign this field
This is the function in DELPHI:
[php]
procedure SetValues(tipo:integer; valor:String='');
begin
With zTable1 do
try
if not (State in [DsEdit, DsInsert]) then
edit;
case tipo of
//Set value to NULL
0:fieldByname(fieldName).Clear;
//Set value to EMPTY
1:fieldByname(fieldName).AsString:='';
else
//Set value to TEXT
fieldByname(fieldName).AsString:=Valor;
end;
finally
try
post;
except
On e:Exception do begin
MessageDlg(E.Message, mtError, [mbOK], 0);
cancel;
end;
end;
end;
end;
[/php]
the function fails when type = 1, I tried putting the character 0 (# 0) instead of double quotes, and in that case no longer returns a NULL value, but that option does not help, because the length of the field and not is 0, otherwise 1.
As a last alternative I upgraded to the latest version of ZEOS and continuous components with the same problem.
Indicate that this same process is working without any problem with ADO components into a MSSQL database
Thanks for your help and greet all