Release 10.1A: OpenEdge Development:
Progress 4GL Reference

> ## CREATE QUERY statement

> Creates a dynamic query.

> #### Syntax

>     CREATE QUERY handle
>      [ IN WIDGET-POOL widget-pool-name ]

> ``handle``

> A variable of type HANDLE that represents the handle of the query object.

> `IN WIDGET-POOL `widget-pool-name``

> An expression of type CHARACTER that evaluates, at run time, to the name of the widget pool that contains the dynamic query.

> Note: Widget pool names are not case-sensitive.

> Example

> The following example creates a dynamic query with a static buffer and a dynamic predicate (WHERE clause) which is resolved at run time:

> r-crtqry.p
>     /* r-crtqry.p */

>     DEFINE VARIABLE qh AS WIDGET-HANDLE.
>     DEFINE VARIABLE numvar AS INTEGER INITIAL 10.

>     CREATE QUERY qh.

>     qh:SET-BUFFERS(BUFFER customer:HANDLE).
>     qh:QUERY-PREPARE("FOR EACH customer WHERE cust-num < " + string(numvar)).
>     qh:QUERY-OPEN.

>     REPEAT WITH FRAME y:
>       qh:GET-NEXT().
>       IF qh:QUERY-OFF-END THEN LEAVE.
>       DISPLAY cust-num
>               name      FORMAT "x(30)"
>               city      FORMAT "X(20)"
>     END.

>     qh:QUERY-CLOSE()
>     DELETE OBJECT qh.

> #### Notes

> - CREATE-QUERY must be followed by the QUERY-PREPARE( ) and QUERY-OPEN() methods before the query can be run.

> - For more information on dynamic queries, see OpenEdge Development: Progress 4GL Handbook .

> #### See also

> CREATE BUFFER statement, DEFINE QUERY statement, QUERY-OPEN( ) method, QUERY-PREPARE( ) method

Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095