bdn.borland.com

Article #30078: dbExpress Error: Invalid Field Type when using a ftDateTime param type with Oracle

Problem:


When I try and use a Parameter of field type ftDateTime in a query with dbExpress, I get the following:
dbExpress Error: Invalid Field Type

Solution:


Rather than use ftDateTime as the param field type, use ftTimeStamp. You will need to create a variable of type TSQLTimeStamp and use the DateTimeToSQLTimeStamp function if you want to convert a TDateTime value to a TSQLTimeStamp. You will need to add: SqlTimSt to your uses clause. Here is a code snippet that demonstrates using SQLTimeStamp:

procedure TForm1.UseTimeStamp(myDate: TDateTime);
var
  mySTS: TSQLTimeStamp;
begin
  mySTS := DateTimeToSQLTimeStamp(myDate);
  with SQLQuery1 do
  begin 
    Params.CreateParam(ftTimeStamp, 'DATE', ptInput);
    ParamByName('DATE').AsSQLTimeStamp := mySTS;
    SQL.Text := 'INSERT INTO PARAMTABLE ' +
                '(DATEFIELD) ' +
                'VALUES (:DATE)';
    ExecSQL(false);
  end;
end;

Last Modified: 16-JUL-03