Just check fp->bytes_written against what you expected to be written. Then use the CHGMSG API to remove from the job log?
Chris
Get Outlook for iOS<
https://aka.ms/o0ukef>
________________________________
From: C400-L <c400-l-bounces@xxxxxxxxxxxxxxxxxx> on behalf of Alexei Baranov <alexei.baranov@xxxxxxxxxx>
Sent: Friday, December 13, 2024 8:21:03 AM
To: C400-L@xxxxxxxxxxxxxxxxxx <C400-L@xxxxxxxxxxxxxxxxxx>
Subject: Re: [C400-L] _Rwrite and _RIOFB_T->dup_key
FYI
I solved the problem myself. I can use exception_handler here.
A little issue - joblog still shows "duplicate key..." despite of _CTLA_HANDLE_NO_MSG (handle and do not log message)
#include <recio.h>
#include <stdio.h>
#include <errno.h>
#include <except.h>
void main(void) {
   char buffer[9999];
   _RFILE *file1 = _Ropen("<some file keyed with UNIQUE=Yes>", "rr+,dupkey=Y");
   _RFILE *file2 = _Ropen("<same file as here ^>",             "rr+,dupkey=Y");
   _RIOFB_T *fb;
   fb = _Rreadf(file1, buffer, file1->buf_length, __NO_LOCK);
#pragma exception_handler(dup_key_error,0,0,_C2_MH_NOTIFY,_CTLA_HANDLE_NO_MSG,"CPF5034")
   fb = _Rwrite(file2, buffer, file2->buf_length);
   if(0) {
dup_key_error:
      printf("Duplicate key found\n");
   }
   return;
}
Regars,
Alexei
-------- Original Message --------
Subject : [C400-L] _Rwrite and _RIOFB_T->dup_key
From    : Alexei Baranov alexei.baranov@xxxxxxxxxx
To      : C400-L@xxxxxxxxxxxxxxxxxx
Cc      :
Date    : Friday, December 13, 2024 15:31
Hello everyone!
I encountered a problem - the _Rwrite does not set the dup_key in _RIOFB_T, when writing a duplicate unique value to unique keyed file.
Tried on several servers, same result everywhere. Has anyone encountered something similar?
My code is simple:
#include <recio.h>
#include <stdio.h>
#include <errno.h>
void main(void) {
   char buffer[9999];
   _RFILE *file1 = _Ropen("<some file keyed with UNIQUE=Yes>", "rr+,dupkey=Y");
   _RFILE *file2 = _Ropen("<same file as here ^>",             "rr+,dupkey=Y");
   _RIOFB_T *fb;
   fb = _Rreadf(file1, buffer, file1->buf_length, __NO_LOCK);
   fb = _Rwrite(file2, buffer, file2->buf_length);
   // Joblog says "Duplicate key on access path"
   // fb->num_bytes==0
   // BUT: fb->dup_key==0!
   // Where I'm wrong?????
   return;
}
--
С уважением,
 Alexei                          mailto:alexei.baranov@xxxxxxxxxx
--
This is the Bare Metal Programming IBM i (AS/400 and iSeries) (C400-L) mailing list
To post a message email: C400-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: 
https://lists.midrange.com/mailman/listinfo/c400-l
or email: C400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at 
https://archive.midrange.com/c400-l.
--
This is the Bare Metal Programming IBM i (AS/400 and iSeries) (C400-L) mailing list
To post a message email: C400-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: 
https://lists.midrange.com/mailman/listinfo/c400-l
or email: C400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at 
https://archive.midrange.com/c400-l.
 
As an Amazon Associate we earn from qualifying purchases.