Consultor Eletrônico



Kbase 18223: User-Defined Functions and Key Fields in ASSIGN Statement
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   16/10/2008
Status: Verified

FACT(s) (Environment):

Progress 8.2x
Progress 8.3A

SYMPTOM(s):

SYSTEM ERROR: Index in for recid could not be deleted. (1422)

Cannot execute user defined function '<function>' in an ASSIGN statement after a key field change. (7954)

Attempt to reference user-defined function '<function>' in an ASSIGN type statement after an assignment to key field '<fieldname>'. (7955)

CAUSE:

Assigning a key field in any statement before a reference to a user-defined function in that same statement has been found to cause index corruption or give run-time error messages.

This applies to any statement that can have multiple assignments in the same statement (e.g. ASSIGN, SET, UPDATE, IMPORT, PROMPT-FOR, CHOOSE).

The following example using the Order and Order-Line tables of the
Sports database illustrates this:

ASSIGN order-line.order-num = order.order-num
order-line.backorder = myFunction().
As of this writing, in Progress releases through 8.2C, attempts to do this may go undetected, or may result in this runtime error:

SYSTEM ERROR: Index "Index Name" in "Table Name" for recid "Recid" could not be deleted. (1422)
In Progress commercial releases 8.3B and above, attempts to do this raise a STOP condition at runtime, and results in one of the following runtime error messages:

Cannot execute user defined function '<function>' in an ASSIGN
statement after a key field change. (7954)

Attempt to reference an user defined function '<function>' in an ASSIGN
type statement after an assignment to key field '<fieldname>'. (7955)


FIX:

To avoid this situation, either:

1) Move all key field assignments after all user-defined function references in the ASSIGN statement:

ASSIGN order-line.backorder = myFunction()
order-line.order-num = order.order-num.
2) Do all key field assignments in a separate ASSIGN statement:

ASSIGN order-line.order-num = order.order-num.
ASSIGN order-line.backorder = myFunction().
This was a problem prior to version 8.3B as the internal code has been changed and now we don't run the function, issue a message, and raise the STOP condition.