How to insert NULL with TMyScript?
Posted: Wed 24 Mar 2010 11:39
Hello,
I use TMyScript to insert data from an Excel table.
With MyScript Do
begin
Sql.Clear;
Sql.Add('insert into mytable');
Sql.Add('(');
Sql.Add('field1,field2');
Sql.Add(')'); // tagok_ezevben_fizetett_osszes_tagdij tagok_hatralek
Sql.Add('values');
Sql.Add('(');
Sql.Add('&field1,&field2');
Sql.Add(')');
Sql.Add('ON DUPLICATE KEY UPDATE ');
Sql.Add('field2=&field2');
end; // With AdatForm.MyScript Do
Then later in a for loop (processing every Excel
MyScript.MacroByName('field2').AsString := SomeValue;
The problem is that "field2" is a Date field in MySql, and sometimes it is not filled in the Excel table, so obviously I got an error: "Incorrect date value".
I though if SomeValue='' then I would use
MyScript.MacroByName('field2').AsString := 'NULL', but this doesn't work, because TMyScript passes this as a string: 'NULL'.
So the question is : how can I insert NULL with TMyScript?
Thank you in advance.
I use TMyScript to insert data from an Excel table.
With MyScript Do
begin
Sql.Clear;
Sql.Add('insert into mytable');
Sql.Add('(');
Sql.Add('field1,field2');
Sql.Add(')'); // tagok_ezevben_fizetett_osszes_tagdij tagok_hatralek
Sql.Add('values');
Sql.Add('(');
Sql.Add('&field1,&field2');
Sql.Add(')');
Sql.Add('ON DUPLICATE KEY UPDATE ');
Sql.Add('field2=&field2');
end; // With AdatForm.MyScript Do
Then later in a for loop (processing every Excel
MyScript.MacroByName('field2').AsString := SomeValue;
The problem is that "field2" is a Date field in MySql, and sometimes it is not filled in the Excel table, so obviously I got an error: "Incorrect date value".
I though if SomeValue='' then I would use
MyScript.MacroByName('field2').AsString := 'NULL', but this doesn't work, because TMyScript passes this as a string: 'NULL'.
So the question is : how can I insert NULL with TMyScript?
Thank you in advance.