How to get FieldCount from a SetSQLCommand?

I want to have a service REST request that can mimic the IDBStatement.ExecuteQuery to run same queries directly from a TXDataClient.
I was thinking of the following:

var St: IDBStatement; Res: IDBResultSet3; var n,i:integer;
res:=st.ExecuteQuery as IDBResultSet3; i:=res.FieldCount;
while res.Next do 
   for n:=0 to i-1 do  

But it seems I can not use the IDBResultSet3. Any other possible solutions?

Hi there.

It depends on the driver/adapter used. Most of them do not implement IDBResultSet3. I guess the solution here is to implement/customise your own adapter.

BTW, unless you want to expose this execute sql stuff in a REST API, why not just use a RemoteDB module?



Indeed, it depends on the driver. What drivers are you using?

FireDAC for mysql, SQLite and Postgres

Indeed, FireDAC adapter doesn't implement IDBresultSet3. But we have added it here, next version will implement it.

It's rather simple you do there in your code though, if you want to. The unit is Aurelius.Drivers.Base, class TDriverResultSetAdapter<T: TDataset>. Just implement the interface there, should be straightforward.

1 Like

This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.