[NEWSboard IBMi Forum]
  1. #1
    Registriert seit
    Feb 2008
    Beiträge
    109

    Frage C-RunTimefunction _rupdate

    Hallo an Alle

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

    Mit
    Code:
    C                   Eval      pIoFb  = RReadN( InpFile        
    C                                            : %Addr( StrBuf )
    C                                            : %Size( StrBuf )
    C                                            : Io_Dft )
    lese ich eine x-beliebige Datei
    Dabei ist
    Code:
     D  StrBuf         s          10240a
    Anschliessen kopiere ich STRBUF in einen Puffer zur Bearbeitung
    Code:
    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
    Code:
    C                   Eval      pIoFb  = RUpdate( InpFile          
    C                                             : %Addr( ReadBuf)  
    C                                             : %Size( ReadBuf ) )
    korrekt?

    Oder wäre
    Code:
    C                   Eval      StrBuf = ReadBuf
    C                   Eval      pIoFb  = RUpdate( InpFile          
    C                                             : %Addr( StrBuf )  
    C                                             : IoNbrBytRw )
    das Richtige?


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

  2. #2
    Registriert seit
    Feb 2001
    Beiträge
    20.695
    _Rupdate()
    Update a Record

    Format
    #include
    _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 files
    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.
    Dienstleistungen? Die gibt es hier: http://www.fuerchau.de
    Das Excel-AddIn: https://www.ftsolutions.de/index.php/downloads
    BI? Da war doch noch was: http://www.ftsolutions.de

  3. #3
    Registriert seit
    Feb 2008
    Beiträge
    109
    ... also Variante 2 .....

    das dachte ich mir schon

    Danke vielmals

Similar Threads

  1. Frage zum Befehl STRPCCMD
    By stoerfang in forum NEWSboard Programmierung
    Antworten: 3
    Letzter Beitrag: 24-01-13, 10:27
  2. Frage zu WDSC bzw. CODE400
    By Mr.iSeries in forum IBM i Hauptforum
    Antworten: 7
    Letzter Beitrag: 02-09-08, 10:16
  3. SQL Frage
    By Bratmaxxe in forum NEWSboard Programmierung
    Antworten: 4
    Letzter Beitrag: 24-01-07, 19:17
  4. Frage zu QZDFMDB2
    By Freezer in forum IBM i Hauptforum
    Antworten: 1
    Letzter Beitrag: 23-10-06, 21:02
  5. Frage zu SQL UserDefinedFunction
    By cbe in forum IBM i Hauptforum
    Antworten: 4
    Letzter Beitrag: 24-08-06, 17:30

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • You may not post attachments
  • You may not edit your posts
  •