Although the Embarcadero documentation says you should use TArrayField casting (it works for Interbase):
procedure TFrmMain.Button1Click(Sender: TObject); var F: TArrayField; V: Variant; begin F := TArrayField(q.FieldByName('data_array')); V := F.FieldValues[0]; ShowMessage(VarToStr(V)); end;
PostgreSQL doesn't seem to work correctly (at least with C ++ builder XE6 I only get the first element of the array). Firedac treats the fields of the PostgreSQL array as nested data sets, so if the above does not work for you, in C ++ you can use the PG array as a regular DataSet, access the elements by moving the cursor, for example:
TDataSetField * TT = (TDataSetField*)q->FieldByName("data_array"); TT->NestedDataSet->RecNo=2;
which translates to delphi in your case will look (maybe with an error):
... var TT: TDataSetField; ... begin TT:= TDataSetField(q.FieldByName('data_array')); while not TT.NestedDataSet.Eof do begin s:= s+ TT.NestedDataSet.Fields.Fields[0].AsString; //0 - only single dimension supported TT.NestedDataSet.Next; end; end;
Yours faithfully
source share