ProvideX V8.20 > Language Reference > 2. Directives
383
ProvideX will not overwrite existing records. Use the DOM= option when you write
to a memory file. The following two examples below insert a new record at index 3
without overwriting the current record at index 3. The record that was at index 3 is
now at index 4 and the number of records in the file has increased by one.
or
WRITE (14,IND=3)IOL=2010
WRITE RECORD (14,IND=3)"DOGCATPIG"
To update a given record in a Memory file, use KEY= with a given key value:
or
0910 WRITE (14,KEY=KK$,DOM=0920)IOL=2010
WRITE RECORD (14,KEY=KK$)A$
Format 2: Write Lock
WRITE (chan[,fileopt])varlist
Use the WRITE LOCK format to ensure that once the file has been written to, it
remains locked; e.g.,
9010 WRITE LOCK (9,ERR=2000)IOL=0110
When you use the LOCK option, ProvideX doesn't release an extracted record. It
maintains the extraction to prevent potential timing problems and maintain counters
and totals in batch processing, sparing you the need to re-extract; e.g.,
9010 WRITE LOCK (9, KEY=K$)
Note: If a serial file is not locked before you write to it, an Error #13: File access
mode invalid will occur on the WRITE directive. Use OPEN LOCK for your serial file
to prevent this error from occurring on the WRITE.
Example:
SERIAL "PVX_SER",,256
0510 OPEN LOCK (5)"PVX_SER"
0520 READ (6)CUST$,NAME$,ADDR1$,ADDR2$,CITY$,PROV$,POSTAL$,START_DT$,CREDLIM,
0520:TERMS,END_DT$,ERR=0550
0530 WRITE (5)IOL=0090
0540 GOTO 0520
0550 STOP
See Also
INSERT Insert New Record in File, p.161
UPDATE Update Existing Record in File, p.349
WRITE RECORD Write Record, p.384
OPEN Open for Processing, p.231,
RCD( ) Function, p.506
'XI' System Parameter, p.692,
*MEMORY* Create & Use Memory File, p.737