Anmelden

View Full Version : Frage C-RunTimefunction _rupdate



ebschubert
26-02-09, 10:44
Hallo an Alle :)

ich habe folgendes - eigentlich triviales - Problem, bin aber kein C-Freak:

Mit

C Eval pIoFb = RReadN( InpFile
C : %Addr( StrBuf )
C : %Size( StrBuf )
C : Io_Dft )
lese ich eine x-beliebige Datei
Dabei ist

D StrBuf s 10240a
Anschliessen kopiere ich STRBUF in einen Puffer zur Bearbeitung

D ReadBuf s 10240a Varying

C Eval ReadBuf = %SubSt( StrBuf
C : 1
C : IoNbrBytRw )
Nachdem ich READBUF bearbeitet habe, will ich diesen per _rupdate zurückschreiben

Ist in diesem Fall

C Eval pIoFb = RUpdate( InpFile
C : %Addr( ReadBuf)
C : %Size( ReadBuf ) )
korrekt?

Oder wäre


C Eval StrBuf = ReadBuf
C Eval pIoFb = RUpdate( InpFile
C : %Addr( StrBuf )
C : IoNbrBytRw )
das Richtige?


Vielen Dank vorab............

Fuerchau
26-02-09, 11:47
_Rupdate() — Update a Record

Format

#include <recio.h>
_RIOFB_T *_Rupdate(_RFILE *fp, void *buf, size_t size);

Language Level: ILE C Extension

Thread Safe: YES. However, if the file pointer is passed among threads, the I/O
feedback area is shared among those threads.

Description

The _Rupdate() function updates the record that is currently locked for update in
the file that is specified by fp. The file must be open for update. A record is locked
for update by reading or locating to it unless __NO_LOCK is specified on the read
or locate operation. If the __NO_POSITION option is specified on a locate
operation the record updated may not be the record currently positioned to. After
the update operation, the updated record is no longer locked.
The number of bytes that are copied from buf to the record is the minimum of size

and the record length of the file (move mode only). If size is greater than the
record length, the data is truncated, and errno is set to ETRUNC. One complete
record is always written to the file. If the size is less than the record length of the
file, the remaining data in the record will be the original data that was read into
the system buffer by the read that locked the record. If a locate operation locked
the record, the remaining data will be what was in the system input buffer prior to
the locate.
The _Rupdate() function can be used to update deleted records and key fields. A
deleted record that is updated will no longer be marked as a deleted record. In
both of these cases any keyed access paths defined for fp will be changed.

Note: If locate mode is being used, _Rupdate() works on the data in the file’s
input buffer.
The _Rupdate() function is valid for database, display (subfiles) and DDM files.

Return Value

The _Rupdate() function returns a pointer to the _RIOFB_T structure associated
with fp. If the _Rupdate() function is successful, the num_bytes field is set to the
number of bytes transferred from the system buffer to the user’s buffer (move
mode) or the record length of the file (locate mode). If fp is a display file, the
sysparm field is updated. If the _Rupdate() function is unsuccessful, the

288 ILE C/C++ for iSeries Run-Time Library Functions V5R2

|
|

num_bytes field is set to a value less than the size specified (move mode) or zero
(locate mode). The errno value will also be changed.
The value of errno may be set to:

Value Meaning
ENOTUPD

The file is not open for update operations.

EIOERROR

A non-recoverable I/O error occurred.

EIORECERR

A recoverable I/O error occurred.

Du solltest also besser die Anzahl gelesener Zeichen angeben.

ebschubert
26-02-09, 11:51
... also Variante 2 .....

das dachte ich mir schon

Danke vielmals :)