Consultor Eletrônico



Kbase P48342: How to get the next 'OBJ' field value in a create trigger
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   15/10/2003
Status: Unverified

GOAL:

How to get the next 'OBJ' field value in a create trigger

GOAL:

How to decrease the size of the create triggers created by Erwin for a Dynamics application

FACT(s) (Environment):

Dynamics 2.0A

FIX:

Create a function with the following code:

FUNCTION getNextObj RETURNS DECIMAL
( /* parameter-definitions */ ) :
/*------------------------------------------------------------------------------
Purpose:
Notes:
------------------------------------------------------------------------------*/
DEFINE VARIABLE dSeqNext AS DECIMAL NO-UNDO.

DEFINE VARIABLE iSeqObj1 AS INTEGER NO-UNDO.
DEFINE VARIABLE iSeqObj2 AS INTEGER NO-UNDO.

DEFINE VARIABLE iSeqSiteDiv AS INTEGER NO-UNDO.
DEFINE VARIABLE iSeqSiteRev AS INTEGER NO-UNDO.

DEFINE VARIABLE iSessnId AS INTEGER NO-UNDO.

RUN ry/app/rygetnobjp.p (INPUT YES, /* increment */
OUTPUT iSeqObj1,
OUTPUT iSeqObj2,
OUTPUT iSeqSiteDiv,
OUTPUT iSeqSiteRev,
OUTPUT iSessnId).

ASSIGN
dSeqNext = DECIMAL((iSeqObj2 * 1000000000.0) + iSeqObj1)
.

IF iSeqSiteDiv <> 0
AND iSeqSiteRev <> 0
THEN
ASSIGN
dSeqNext = dSeqNext + (iSeqSiteRev / iSeqSiteDiv).

RETURN dSeqNext.
END FUNCTION.


In the create trigger use that include like the following example:

TRIGGER PROCEDURE FOR CREATE OF callTracking.

{includeCreatedAbove}

ASSIGN table.field_obj = getNextObj().