Hello.
Given this code:
// v_int : TLongIntFirld
// v_txtc: TStringField
// v_txtt: TMemoField
const
CSQL = 'INSERT INTO uc_temp (v_int, v_txtc, v_txtt) VALUES (%d, %s, %s);';
var
LtextSQL: string;
Lf1: LongInt;
Lf2, Lf3: String;
begin
if not TryStrToInt(Edit1.Text, Lf1) then
begin
// Lf1 = Null;
end;
Lf2 := Edit2.Text;
if Trim(Lf2) = '' then
begin
// Lf2 = Null;
end;
Lf3 := Memo2.Text;
if Trim(Lf3) = '' then
begin
// Lf3 = Null;
end;
LtextSQL := Format(CSQL, [Lf1, Lf2, Lf3]);
Memo1.Append(LtextSQL);
Self.ZQuery1.SQL.Clear;
// ...
end;
My Question is, How to Convert Empty Value ( for string = '', for Integer = '' ) to Null, in order to when executing
sql statement, the Empty value will be replaced by NULL.
IN my exemple, I use Edit & Memo to get input values, if they are empty then I Format the query with NULL
Ie:
LtextSQL := INSERT INTO uc_temp (v_int, v_txtc, v_txtt) VALUES (NULL, NULL, NULL);
PS: I do not want to construct the query using string concatination.