I had a problem getting a list of fields from a query that was determined by users of my program at runtime. I allow my users to enter an SQL query into the memo control, and then I want them to go through the returned fields and do things like formatting output values, column sums, etc. So, I need to get the column names so that they can provide additional information.
I would do everything so that there are no parameters, but I should also let them determine the filter parameters for the request. So, if I want to set the parameters to null, I should know what the parameter data type is.
I am using Delphi 2006. I am connecting to the Firebird 2.1 database using DBExpress TSQLConnection and TSQLQuery. I used to successfully use:
for i: = 0 for Qry.Params.Count - 1 do Qry.Params [i] .value: = varNull;
I found that I had a problem when I tried to use the date parameter. It was just a coincidence that all my parameters before that were integers (record identifiers). It turns out that varNull is just an enumerated constant with a value of 1, so I get acceptable results (no entries) it works fine.
I only need a list of fields. Perhaps I just need to parse the SELECT clause of the SQL statement. I thought setting up Qry.Prepared to True would get me a list of fields, but there would be no such luck. He wants values for the parameters.
, . .