INFORMIX
Visionary User's Guide
Chapter 3: Creating Data Sources
Home Contents Index Master Index New Book

Adding Query Parameters

A query parameter is value assigned to a variable that is set at runtime before the query is executed. A query parameter is available in the scene in which the data source is defined.

When you define a query parameter, you are creating a parameterized query. A parameterized query is not a separate type of query; rather, it extends the flexibility of other queries. You use parameterized queries to simplify the process of changing query criteria.

Query parameters are preceded by a colon in an SQL expression and are displayed in the SQL Text view of the Query Editor. In this example, the query parameter Dbacklog has been set for the backlog column:

The Object Inspector displays each query parameter as a property of the data element object. For example, when you create a query parameter, the Object Inspector displays the QueryParameter object called LayoutNameN.-
DataElementN.QueryName
for any scene in which that data source is used in a layout.

Figure 3-40
Query Parameter Child Object

The values contained in the object are used to set the properties of the query at runtime before the query is executed. If the query is not parameterized, the QueryParameter child object is not displayed in the Object Inspector.

Important: If the parameter value is not set in the Query Parameter child object of the data element and the default value is not specified, the parameter cannot be evaluated in the SQL expression.
For more information on data elements and object properties, see "Displaying Data in a Scene" and "Modifying Object Properties".

Inserting Query Parameters

Use the Query Parameter dialog box to insert and define query parameters. You access the Query Parameter dialog box in one of the following ways:

For detailed instructions on inserting and defining query parameters using the Advanced Query wizard, see "Advanced Query Wizard".

To insert a query parameter using the Query Diagram view

    1. Choose Insert Data Source to display the New Data Source dialog box.

    2. Select Query Diagram View from the list box and click OK to display the Query Editor.

    3. Double-click the Table, Parameter, Filter, and Output blocks to place them in the Query Diagram view.

    4. Click the Input and Output ports to connect the query blocks.

    5. Right-click the Parameter block and select Properties to display the Query Parameter dialog box.

    Figure 3-41
    Defining a Query Parameter

    6. Type a parameter name in the Parameter name text box.

    7. Select a data type from the Data type list box. The data type is used to cast the value of the parameter in the SQL query before it is submitted to the database.

    8. Optionally, provide a short description of the parameter.

    9. Check the Has default value check box and type the default value of the column in the text box. If you do not provide the default value, the results cannot be viewed in the data sheet.

    10. Click OK.

    11. Define the remaining query block properties. For detailed instructions on creating queries using the Query Diagram view, see "What Are Data Sources?".

    12. Click SQL Text to view the generated SQL text.

    13. Click Data Sheet to view the results of your query.

Modifying Query Parameters

Use the Data Sources panel in the World Manager to modify query parameters.

To modify query parameters

    1. Click the Worlds tab and click Data Sources to display the Data Sources panel.

    2. Navigate to the query in which you want to modify the query parameter.

    3. Expand the Parameters folder.

    4. Right-click the query parameter and select Properties to display the Query Parameter dialog box.

    5. Modify the parameter properties and click OK.




Visionary User's Guide, version 1.0
Copyright © 1998, Informix Software, Inc. All rights reserved.