Kbase P16110: How to handle errors using DataServer for Microsoft SQL Serv
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  1/28/2003 |
|
Status: Unverified
GOAL:
How to handle errors using DataServer for Microsoft SQL Server
FIX:
When an error occurs, Progress tries to resolve it by working back through the procedure, looking at each block header until it finds the closest block with the error-handling property, and then undoing and retrying the block. (See the Progress Programming Handbook for more information about error handling.)
However, because the DataServer is accessing a non-Progress data source, Progress cannot detect the errors until the end of a transaction block. Therefore, if an error occurs in a subtransaction, Progress cannot detect it until the end of the entire transaction block and must perform default error handling for the entire transaction block.
The VALIDATE statement causes the DataServer to send requests to your MSS data source, so incorporate it into your error-handling technique.
Example:
DEFINE VAR j AS INTEGER.
DO TRANSACTION:
CREATE customer NO-ERROR.
ASSIGN cust-num = 45 NO-ERROR.
VALIDATE customer.
IF ERROR-STATUS:ERROR THEN DO:
MESSAGE "error: number of messages = " ERROR-STATUS:NUM-MESSAGES.
DO j = 1 TO ERROR-STATUS:NUM-MESSAGES:
MESSAGE "error" ERROR-STATUS:GET-NUMBER(j)
ERROR-STATUS:GET-MESSAGE (j).
END.
UNDO, LEAVE.
END.
ASSIGN name = "Smith" NO-ERROR.
VALIDATE customer.
IF ERROR-STATUS:ERROR THEN . . .
END.
This code returns data-source errors after the VALIDATE statement.