Change Field Value "empty string" -> "null"
-
- Posts: 5
- Joined: Fri 02 Apr 2010 11:24
Change Field Value "empty string" -> "null"
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...
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...
-
- Posts: 5
- Joined: Fri 02 Apr 2010 11:24
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.
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.
-
- Posts: 5
- Joined: Fri 02 Apr 2010 11:24
-
- Posts: 5
- Joined: Fri 02 Apr 2010 11:24