I'm running a texis query using the API (openserver, n_regtexiscb, n_texis...).
When the query returns results, it is easy for me to get the field names/types (ie the select part of the query) in the callback function.
But if the query returns nothing the callback function is never called and I can't retrieve the field names/types.
I don't want to have to parse the sql query myself (too dangerous), I would rather be able to ask texis for the results of its parsing.
Is that feasible?
The FLDLST struct contains the field names. If there are no results there's no way to get the names.
As an aside, I'd recommend either the n_opentsql or n_opentx family of calls over the callback method. Callbacks can be messy to deal with. That won't change the answer to your question though.
How does the tsql program work?
If I run the query with it, it will return a header with the name of the fields requested even if no records are returned.
Any change I can emulate/reuse the same technique?
If you use the TX family of calls there is a n_fldnames() call that is in the header file, but not documented, that will return the list of field names from the query.