Does anyone have a working example of accessing array elements from a TFDQuery TDataSetField when working with Postgresql. I have tried as many options as I can based on the very sparse documentation and Stackoverflow questions to no avail. I am using 10.1 Berlin.
Can you share your table ddl ? I'll create it on my Postgresql server and try to get you a pascal snipset
ReplyDeleteI was looking at the sample code provided with Delphi and modified the example DDL as follows:
ReplyDeletecreate type tp_test as (x bigint, y bigint);
create table fdqa_array (
id integer not null primary key,
name varchar (20),
test_complex tp_test [5]);
I want to access the array elements that make up the column test_complex.
When using SELECT * FROM TABLE in FireDac, what fields (fieldtype) do you get back for test_complex? Do you get the test_complex.x and test_complex.y fields separate back? (You can always specify test_complex.x and .y in your select statements to get two TLargeIntField (or something).
ReplyDeleteI may be going some way to answering this myself. How the fields are represented depends upon the connection parameter "ArrayScanSample". Initially, I was just seeing an error. By changing "ArrayScanSample" to '0;0' I see TDataSetField returned. The NestedDataSet contains a TADTField, which I think represents the composite type. So, it looks as though I am going to need to examine the contents of this somehow.
ReplyDeleteOK. Got it. The TADTField has fields and fieldvalues properties just like a data set, so I just need to use them to access what I need.
ReplyDeleteThanks for taking the time to try helping out.
There is a problem with Postresql and FireDac, however. FireDac does not appear to support record types correctly when working with Postgresql. Perhaps back to the drawing board...
ReplyDelete