retrieving the field names from a query

Post Reply
tony.malandain
Posts: 57
Joined: Sat Mar 27, 2004 6:39 pm

retrieving the field names from a query

Post 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.
User avatar
mark
Site Admin
Posts: 5519
Joined: Tue Apr 25, 2000 6:56 pm

retrieving the field names from a query

Post 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.
tony.malandain
Posts: 57
Joined: Sat Mar 27, 2004 6:39 pm

retrieving the field names from a query

Post 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?
User avatar
John
Site Admin
Posts: 2622
Joined: Mon Apr 24, 2000 3:18 pm
Location: Cleveland, OH
Contact:

retrieving the field names from a query

Post 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.
John Turnbull
Thunderstone Software
tony.malandain
Posts: 57
Joined: Sat Mar 27, 2004 6:39 pm

retrieving the field names from a query

Post by tony.malandain »

Thank for the tip.

/T.
tony.malandain
Posts: 57
Joined: Sat Mar 27, 2004 6:39 pm

retrieving the field names from a query

Post 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?
User avatar
mark
Site Admin
Posts: 5519
Joined: Tue Apr 25, 2000 6:56 pm

retrieving the field names from a query

Post by mark »

The resultant FLDLST will have the types. No way to get types if there are no results.
Post Reply