Change Field Value "empty string" -> "null"

Change Field Value "empty string" -> "null"

Postby Maurizio Belvisi » Fri 02 Apr 2010 14:47

My enviroment:
Windows XP
Delphi 2007 W32 (R2) + dbexpida40.dll (v. 2.20.10)
Firebird 1.5

The problem:
I have a table this table
CREATE TABLE TABLETEST (
ID INTEGER NOT NULL,
FIELDREQUIRED CHAR(10) NOT NULL
);

I try to inser record with SQLDataSet+DataSetProvider+ClientDataSet, this part of code:
... CUT ...
ClientDataSet1.Insert;
ClientDataSet1ID.AsInteger:=1;
ClientDataSet1FIELDREQUIRED.AsString:=' ';
ClientDataSet1.Post;
ClientDataSet1.ApplyUpdates(0);
... CUT ...

The ApplyUpdates fails for:
validation error for column FIELDREQUIRED, value "*** null ***"

My analysis:
In Provider.pas the value of parameter n° 2 (for column FIELDREQUIRED) is set to '', correctly.
Part of Provider.pas:
FieldLine := WideFormat('%s%s%s%s%2:s, ', [FieldLine, PSQLInfo(Tree.Data)^.QuotedTableDot,
QuoteChar, Field.Origin]);
ParamLine := ParamLine + '?, ';
***** >> Value := Field.NewValue; << ********
if VarIsClear(Value) then Value := Field.OldValue;
TParam(Params.Add).AssignFieldValue(Field, Value);
end;

Provider.pas Line 4095 (in the "TSQLResolver.GenInsertSQL").

This i ok but with dll "dbexpida40.dll" not work, otherwise with ""dbxint30.dll" work !!

Help me!
Thk

PS: I tired to use "Contact Form" for send a example, but not work...
Maurizio Belvisi
 
Posts: 5
Joined: Fri 02 Apr 2010 11:24

Postby Maurizio Belvisi » Fri 02 Apr 2010 15:49

Add information.
Follow part of trace log (make with DBXTrace) for "dbxint30.dll" and "dbexpida40.dll".

********** dbxint30.dll ********************

[... CUT ...]

{COMMAND } CommandC1_4.Text := 'insert into "TABLETEST"'#13''#10''
+' ("ID", "FIELDREQUIRED")'#13''#10''
+'values'#13''#10''
+' (?, ?)'#13''#10'';
{DRIVER VENDOR } {INTERBASE - isc_dsql_allocate_statement}
{PREPARE } CommandC1_4.Prepare;
{DRIVER VENDOR } {insert into "TABLETEST"
("ID", "FIELDREQUIRED")
values
(?, ?)
}
{DRIVER VENDOR } {INTERBASE - isc_dsql_prepare}
{DRIVER VENDOR } {INTERBASE - isc_dsql_sql_info}
{DRIVER VENDOR } {INTERBASE - isc_vax_integer}
{DRIVER VENDOR } {INTERBASE - isc_dsql_describe_bind}
{PARAMETER } CommandC1_4.Parameters[0].Value.SetInt32(1);
{PARAMETER } CommandC1_4.Parameters[1].Value.SetAnsiString('');
{COMMAND } ReaderC1_4_1 := CommandC1_4.ExecuteQuery;
{DRIVER VENDOR } {INTERBASE - SQLDialect = 3}
{DRIVER VENDOR } {INTERBASE - isc_dsql_execute}
{EXECUTE } RowsAffectedC1_4 := CommandC1_4.RowsAffected
{EXECUTE } {RowsAffectedC1_4 = 1}

[... CUT ...]


********** dbexpida40.dll ********************

[... CUT ...]

{COMMAND } CommandC1_3.Text := 'insert into TABLETEST'#13''#10''
+' (ID, FIELDREQUIRED)'#13''#10''
+'values'#13''#10''
+' (?, ?)'#13''#10'';
{PREPARE } CommandC1_3.Prepare;
{PARAMETER } CommandC1_3.Parameters[0].Value.SetInt32(1);
{PARAMETER } CommandC1_3.Parameters[1].Value.SetAnsiString('');
{COMMAND } ReaderC1_3_1 := CommandC1_3.ExecuteQuery;
{DRIVER EXECUTE } {INSERT INTO TABLETEST
(ID, FIELDREQUIRED)
values
(?, ?)
:1 (Int32,IN) = 1
:2 (String,IN) =
}
{DRIVER ERROR } {Error:
validation error for column FIELDREQUIRED, value "*** null ***"}
{ERROR } {Error Code: 65535
validation error for column FIELDREQUIRED, value "*** null ***"}
{COMMAND } FreeAndNil(CommandC1_3);

[... CUT ...]


The empty string is changed in NULL from the driver dbexpida40.dll.

Plese give me a fix !

Thanks

M.B.
Maurizio Belvisi
 
Posts: 5
Joined: Fri 02 Apr 2010 11:24

Postby Dimon » Tue 06 Apr 2010 07:39

To solve the problem set the ClientDataSet1.DisableStringTrim property to True.
Dimon
Devart Team
 
Posts: 2885
Joined: Mon 05 Mar 2007 16:32

Postby Maurizio Belvisi » Tue 06 Apr 2010 09:23

Dimon wrote:To solve the problem set the ClientDataSet1.DisableStringTrim property to True.


I try but not work.
I get the same error.

I can send a example (test project) if needed...
Maurizio Belvisi
 
Posts: 5
Joined: Fri 02 Apr 2010 11:24

Postby Dimon » Tue 06 Apr 2010 09:33

Yes, send me a sample to demonstrate the problem to dmitryg*devart*com.
Dimon
Devart Team
 
Posts: 2885
Joined: Mon 05 Mar 2007 16:32

Postby Maurizio Belvisi » Tue 06 Apr 2010 10:10

Ok, sent now.
Maurizio Belvisi
 
Posts: 5
Joined: Fri 02 Apr 2010 11:24

Postby Dimon » Wed 07 Apr 2010 07:07

We have fixed this problem in the latest DbxIda build (2.50.22). Please, upgrade to this build to solve the problem.
Dimon
Devart Team
 
Posts: 2885
Joined: Mon 05 Mar 2007 16:32

Postby Maurizio Belvisi » Wed 07 Apr 2010 15:07

Ok, now work fine!
Bug fixed in a few days!

The fix was very important to me! Thanks.


M.B.
Project Manager
Application Architect
Maurizio Belvisi
 
Posts: 5
Joined: Fri 02 Apr 2010 11:24

Postby Dimon » Thu 08 Apr 2010 07:37

It is good to see that this problem has been solved. If any other questions come up, please contact me.
Dimon
Devart Team
 
Posts: 2885
Joined: Mon 05 Mar 2007 16:32

Postby Alian_Morris » Tue 21 Feb 2012 12:46

Dimon wrote:We have fixed this problem in the latest DbxIda build (2.50.22). Please, upgrade to this build to solve the problem.

Thanks, Dimon, for the assistance. I've already tried to cope with the problem myself :? Pondok Cerita
Alian_Morris
 
Posts: 2
Joined: Tue 21 Feb 2012 12:39


Return to dbExpress driver for InterBase & Firebird