Consultor Eletrônico



Kbase 13010: Load procedure to both CREATE and UPDATE - replace - records
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   10/05/1998
Load procedure to both CREATE and UPDATE - replace - records

How can you IMPORT data into a PROGRESS database when
some of the records are to be CREATED, and some already
exist and merely need to be UPDATED?

If the sending application does not include a "status/action"
field which indicates whether the record is an
ADD/CHANGE/DELETE, then use the following strategy:

- Go to Dictionary/Utilities/Include files/Assign
and make an include file for the table to load to.

The load program will essentially be:

def workfile wf-filex LIKE filex. /* "filex" is the one in the dict*/
input from filex.d.
repeat:
create wf-filex.
import wf-filex.
find filex where filex.key = wf-filex.key EXCLUSIVE-LOCK NO-WAIT
NO-ERROR.
IF LOCKED filex THEN
DO:
<figure out what you want it to do if locked>.
next.
end.
ELSE
IF NOT AVAILABLE filex THEN
DO:
CREATE filex.
ASSIGN filex.key = wf-filex.key.
END.
{filex.i} /*< Use the modified assign include file you just */
/* built for all the non-primary key fields. */
DELETE wf-filex.
END.

Progress Software Technical Support Note # 13010