GetFieldName in IDBResultSet?

I'm starting to extract data from IDBResultSet with a SQL that uses the canonical "Select * from..." to fill a class to perform calculations on.
How can I get the field names from the IDBResultset to loop and assign values ​​to the class?
Missing a GetFieldName(i) function? Or is there another direct way to fill a custom class directly from IDBResultSet?
(It seems that are missing convenient functions that directly export the resultset to Json or to a class).
Thanks in advance for the help.
Good work!

You can get IDBResultSet2 interface from IDBResultSet and use GetFieldIndex method:

Thanks for the support.
But what I want to know, precisely to generalize marshalling functions, is the name of the fields, which I may not know in advance.
It seems logical to me to be able to do, in a generic function, a simple
"for i= 0 to fieldcount
do Mydummy.Add(FieldName(i) + '=' +Fieldvalue(i))
But fieldvalue you can handle it easily but a function to extract the fieldname does not exist.
It seems like a basic question to me.
Or am I doing something wrong?

In the same link I provided you, the last post mentions the alternative use of IDBDatasetStatement. That's what you can use in this case.

OK Wagner,
I'm asking too much if it is possible to insert a missing feature (GetFieldName) in the next updates?
I want to use IDBResult precisely to avoid the slow dataset, otherwise I use a TFDquery directly, without much effort.
Thanks and good job

The dataset wouldn't be slow. In the end, Aurelius uses dataset underlying, unless you are using the native driver? Aren't you using the FireDAC adapter?

Yes I am using Firedac.
But, I would like to avoid an extra step and an additional layer if just one (simple) function is enough to solve the problem.
If you created the native drivers it is certainly to avoid using datasets (DB->dataset->Class->Json) which are not suitable in a server product, and you certainly did it to increase performances.
If this is your policy, ok. But honestly I don't think I'm asking for much, and if to have the name of a field of a IDBResultset I have forcefully to manage a dataset, there's something wrong, because we're talking about a SERVER product. If I have to manage thousands of connections I necessarily have to take these aspects into account (Even if Aurelius uses the dataset to fetch the data, preference goes to the native drivers, the effects).
Good job.

It's not asking too much. It's just not there yet. The dataset option is not (currently) an overhead and is available already. So you can use it right now.

Yes, please file a feature request for such additional features in the interfaces. We can schedule to implement it at some point.

Ok, Wagner, doned.
Good job

1 Like