Re: [gnome-db] metadata



On Mon, 15 Nov 2004 08:25:24 -0700, Neil Zanella <nzanella gmail com> wrote:
> Hello,
> 
> Suppose I have an SQL query. What I would like is methods which allow
> me to access
> the name and types of the fields which would be produced if the query were to be
> executed. Is this possible or need I do it manually myself?
> 

Using libmergeant, you can create a MgQuery object with
mg_query_new_from_sql(), and then test if the SQL has been parsed
correctly (if mg_query_get_query_type(query) !=
MG_QUERY_TYPE_NON_PARSED_SQL). If the parsing was correct, then you
can use the MgEntity interface on that object (for example
mg_entity_get_fields (MG_ENTITY (query)) and browse through the list
of MgField objects).

If the query has not been parsed (the parser is not complete), then
you can't do it that way (or you can improve the parser...).

For examples of queries which can be parsed, have a look at the
testing/SQL_tests.xml file which lists queries used for the parser
test.

Regards,

Vivien



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]