Consultor Eletrônico



Kbase 20341: How to Trap Errors on the QUERY-PREPARE Method?
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   09/01/2007
Status: Verified

GOAL:

How to program the QUERY-PREPARE method of the Query object handle to trap errors?

GOAL:

How to Trap Errors on the QUERY-PREPARE Method?

GOAL:

Why doesn't the QUERY-PREPARE method set the ERROR-STATUS:ERROR flag?

FACT(s) (Environment):

Progress 8.x
Progress 9.x
OpenEdge 10

FIX:

When you want to trap errors you normally use the NO-ERROR option on different statements.
This also applies to the QUERY-PREPARE method of the Query object handle, where you set the ERROR-STATUS:ERROR attribute to TRUE and you can go through the errors by querying the ERROR-STATUS:GET-MESSAGE() method.

For the Query object's QUERY-PREPARE method a slightly different scenario must be programmed. The error is returned on the return value from the method, so you should code a variable defined as logical then use that variable to query (or display) the return value from the method.

The method does not set the ERROR-STATUS:ERROR flag. This is documented in the on line help with:

"If the QUERY-PREPARE method encounters an error, it returns FALSE and does not raise an error. If you use the QUERY-PREPARE method in a statement that uses the NO-ERROR option and an error occurs, the QUERY-PREPARE method still returns FALSE and does not raise an error. You can get information on the error through the GET-MESSAGE method of the ERROR-STATUS system handle, as usual."