Consultor Eletrônico



Kbase P97633: How to trap the error (4212) with Oracle DataServer?
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   19/11/2004
Status: Unverified

GOAL:

How to trap the error (4212)

GOAL:

Is it possible to intercept the error (4212) with the NO-ERROR option

GOAL:

A column in this row being inserted or updated is too large (4212)

FACT(s) (Environment):

Oracle DataServer

FIX:

Yes, this is possible, but the NO-ERROR option should be added on the VALIDATE statement.


This error happens when the client layer asks the database layer (in this case, the DataServer) to validate a record.
Usually this happens at the end of a transaction, unless you have a VALIDATE or RELEASE statement in the application before the end of the transaction.
The error does not happen when the value is assigned, and the value does *not* get propagated to the Oracle database, therefore there is no corruption.

When the record is about to be written into the Oracle database, the ORACLE DataServer goes through the changes, checks the maximum size of the column in the schema information (in the schema holder) and generates the error when it finds that the data is larger than the field's max length.

However, the VALIDATE does not undo the record update, the info is still in the record buffer, and the transaction is still open, so the error actually happens at the end of the procedure (when the transaction ends). That is the reason why the UNDO statement has also to be added otherwise the error message will still appear.

For example:
DO TRANSACTION:
FIND FIRST customer.
ASSIGN NAME = FILL("a",35) NO-ERROR.
VALIDATE customer NO-ERROR.
IF ERROR-STATUS:ERROR THEN DO:
/* < some error processing> */
UNDO, LEAVE.
END.
END.
See below an example of error processing. A message "Value is too large !" appears instead of the error 4212.

DO TRANSACTION:
FIND FIRST customer.
ASSIGN NAME = FILL("a",35) NO-ERROR.
VALIDATE customer NO-ERROR.
IF ERROR-STATUS:ERROR THEN DO:
IF ERROR-STATUS:GET-NUMBER(1) = 4212 THEN
MESSAGE "Value is too large !" VIEW-AS ALERT-BOX INFO BUTTONS OK.
UNDO, LEAVE.
END.
END.