Wow, found this (
https://www.ibm.com/docs/en/i/7.2?topic=paths-duplicate-key-values):
"If an I⁄O operation on a record is successful and a duplicate key value is found in that record, the dup_key flag in the _RIOFB_T structure is set."
But how to understand that my I/O operation on a record is _un_successful because of duplicate keys? In RPGLE, we can monitor 01021 exceptions on WRITE statements. But what about C?
Regards,
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;                                                     
}                                                              
 
As an Amazon Associate we earn from qualifying purchases.