문제

I am creating a temp table in SQL and then adding a new field to it. It seems Firedac is caching the field list for this temp table.
The following code gives me "FDQuery5: Field 'Available' not found."

  FDQuery5.Connection := FDConnection1;
  FDConnection1.ExecSQL('Select StockNo into #Temp from Stock');
  FDQuery5.SQL.Text := 'Select * From #Temp';
  FDQuery5.open;
  FDConnection1.ExecSQL('Alter Table #Temp add Available Char(1)');
  FDQuery5.Close;
  FDQuery5.open;
  ShowMessage(FDQuery5.FieldByName('Available').AsString);

using XE5 with Firedac. I have tried Connection.RefreshMetadataCache and I have removed fiMeta from FetchOptions.Cache.

I can get Firedac to recognise the new field if I modify the SQL.Text. This is undesirable as my application will need modifying in quite a few places.

도움이 되었습니까?

해결책

The query remains prepared after you call FDQuery5.Close. That means, it caches also result set structure. To prepare the query replace FDQuery5.Close with FDQuery5.Disconnect.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top