Page 1 of 1

retrieving the field names from a query

Posted: Tue Nov 30, 2004 4:43 pm
by tony.malandain
Hi,

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?

Thanks,
/Tony.

retrieving the field names from a query

Posted: Tue Nov 30, 2004 5:55 pm
by mark
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.

retrieving the field names from a query

Posted: Tue Nov 30, 2004 6:02 pm
by tony.malandain
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?

retrieving the field names from a query

Posted: Thu Dec 02, 2004 11:57 am
by John
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.

retrieving the field names from a query

Posted: Thu Dec 02, 2004 12:17 pm
by tony.malandain
Thank for the tip.

/T.

retrieving the field names from a query

Posted: Tue Oct 25, 2005 10:27 am
by tony.malandain
John,

Thanks for the info. A quick question though:
This function returns the field names, but not their types. Any idea of I could get their types?

retrieving the field names from a query

Posted: Tue Oct 25, 2005 1:17 pm
by mark
The resultant FLDLST will have the types. No way to get types if there are no results.