Unofficial Content
  • This documentation is valid for:

Gxquery4 - GXqueryQuery data type

GeneXus provides a GXquery API that allows developers to handle data types and methods to integrate queries made through GXquery within a GeneXus application.

The GXqueryQuery data type is used to recover information about the queries in the metadata, such as their name and description.


Name Query name.
Description Query description.



GetInformation   It gets information about a query, wich means that it returns an object with the query's information in the method name.
     Errors Out It's the errors, loaded by the method when an error occurs.
Execute   It executes a query and returns an string with the query information.
     Parameters  In It's a collection with the parameters name and their values.
     OutputFormatId  In It's the output format ID.
     ServiceOptions  In Based on GXqueryExecuteQueryServiceOption data type.
     Errors Out It's the errors, loaded by the method when an error occurs.



The following example shows how we can obtain the number of queries and how to load a combo box with the list of queries.

First, we need to indicate to GXquery which metadata we need. To do this, we use the SetMetadata method of the GXquerySession data type. Next, we take the list of queries using the GetQueries method of the same data type.

If no errors occur, we use the Count method to find the number of queries in the metadata and display this in a character variable.

Finally, using the For command, we load the combo box with the query name.

Event 'GetQueries'
    &GXquerySession.SetMetadata('TravelAgency', &Errors)
    &GXqueryQueries = &GXquerySession.GetQueries(GXqueryGetQueriesOption.AllQueries, &Errors)
    If &Errors.Count > 0
        &GetQueriesStatus = &Errors.Item(1).Message
        &QueriesCount = &GXqueryQueries.Count
        &GetQueriesStatus = "Queries count: " + &QueriesCount.ToString().Trim()
        For &GXqueryQuery in &GXqueryQueries
            &QueryName.AddItem(&GXqueryQuery.Name, &GXqueryQuery.Name)

In the following example, we set the query to show and execute this.

&GXqueryQuery = &GXquerySession.GetQueryByName('AttractionsBycountries', &Errors)
&QueryResult = &GXqueryQuery.Execute(&GXqueryRuntimeParameters, &OutputFormatId, &GXqueryExecuteQueryServiceOptions, &Errors)
QueryViewer1.IsExternalQuery = True
QueryViewer1.ExternalQueryResult = &QueryResult

See also


As of GXquery 4.0 Upgrade 3 the GetInformation() method also return the elements of a Query.


Last update: November 2023 | © GeneXus. All rights reserved. GeneXus Powered by Globant