Consultor Eletrônico



Kbase 17791: How to determine via the 4GL if a query has been opened
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   5/10/1998
How to determine via the 4GL if a query has been opened

The GET statement returns a record for an open query. If the query is
not currently open, either because an OPEN QUERY statement has not
been executed, or because the query has been closed by a CLOSE QUERY
statement, using the GET statement will result in the following error:

Cannot Get on query <query> which is not opened. (3159)

There is no NO-ERROR option for the GET statement, so this error can
not be suppressed. Therefore if you wish to use the GET statement at
a point in your code where you can't be certain if the query is open,
you need to test if the query is open and conditionally execute the
GET statement based on that test. This can be accomplished using the
NUM-RESULTS function.

The NUM-RESULTS function returns the number of rows currently in the
results list of a query. If the query is not open, NUM-RESULTS returns
the unknown value (?). So the following code will execute the GET
statement only if the query is open, avoiding error 3159 shown above:

IF NUM-RESULTS(<query-name>) <> ? THEN
GET NEXT <query>.
ELSE
<alternative code>


REFERENCES TO WRITTEN DOCUMENTATION:
Progress Language Reference, GET statement
Progress Language Reference, NUM-RESULTS function

Progress Software Technical Support Note # 17791