insert into MyTable (Fields1,Field2,Field3) values ('Sweets',934,to_date('21/05/2001','dd/mm/yyyy')) неправда ли она более проста в использовании ?
Здесь представлены функции SqlInsert и SqlUpdate. Вы наверное заметили, что я передаю TDateTime приведённый как Variant. Причина кроется в том, что VType в array of const не имеете TDateTime типа и даты просто представлены как vtExtended.
Функция SqlInsert имеет 2 переопределённых вызова, которые позволяют Вам включить или выполнить массив имён колонок.
Delete(RetVar,length(RetVar),1); RetVar := RetVar + ')'; if High(Values) < High(ColNames) then ShowMessage('SQL Insert - Not enough values.'); if High(Values) > High(ColNames) then ShowMessage('SQL Insert - Too many values.');
Result := RetVar; end;
function SqlInsert(Values : arrayofconst; TableName : string) : string; overload; var RetVar : string; i : integer; begin RetVar := 'insert into ' + TableName + CrLf; RetVar := RetVar + 'values (';
Delete(RetVar,length(RetVar),1); RetVar := RetVar + CrLf + 'where ' + WhereClause; if High(Values) < High(ColNames) then ShowMessage('SQL Update - Not enough values.'); if High(Values) > High(ColNames) then ShowMessage('SQL Update - Too many values.');