Page 1 of 1

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

Posted: Fri 02 Apr 2010 14:47
by Maurizio Belvisi
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...

Posted: Fri 02 Apr 2010 15:49
by Maurizio Belvisi
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.

Posted: Tue 06 Apr 2010 07:39
by Dimon
To solve the problem set the ClientDataSet1.DisableStringTrim property to True.

Posted: Tue 06 Apr 2010 09:23
by Maurizio Belvisi
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...

Posted: Tue 06 Apr 2010 09:33
by Dimon
Yes, send me a sample to demonstrate the problem to dmitryg*devart*com.

Posted: Tue 06 Apr 2010 10:10
by Maurizio Belvisi
Ok, sent now.

Posted: Wed 07 Apr 2010 07:07
by Dimon
We have fixed this problem in the latest DbxIda build (2.50.22). Please, upgrade to this build to solve the problem.

Posted: Wed 07 Apr 2010 15:07
by Maurizio Belvisi
Ok, now work fine!
Bug fixed in a few days!

The fix was very important to me! Thanks.


M.B.
Project Manager
Application Architect

Posted: Thu 08 Apr 2010 07:37
by Dimon
It is good to see that this problem has been solved. If any other questions come up, please contact me.