I have a stored procedure to create a record in a SQL table. That SQL table
has an auto-identity column which I need to pass back to the RPG so I used
a *data-change-table-reference *(i.e. SELECT <fields> FROM FINAL TABLE
(INSERT ...)) and then used ALLOCATE CURSOR in RPGLE to retrieve the result
set.
This works perfectly for the first record created, but on the second call
of the SP I receive a CPF5035 Data Mapping Error (followed by SQLCOD=-138
and SQLSTT='22011'):
CPF5035 . . . . : A data mapping error occurred on field BEKEYV in record
number 0, record format FORMAT0001, member number 1, in member BENEVENT
file
BENEVENT in library BAILEYP, because of error code 14.
14 -- The length of a variable length field is not valid or the data in
a
substring variable is not valid.
The column BEKEYV is defined as a VARCHAR(100) , and the RPG field passed
into the SP is defined LIKE(BEKEYV) so I can't understand why I am getting
a data mapping error. I am not using any form of substring (inc. LEFT,
RIGHT, etc.) Debugging the RPG code shows no obvious problems in the fields
passed to the SP on the first or second call.
The SP definition script is shown here:
https://pastebin.com/pjJ8LnEY
The RPG code calling the SP is shown here:
https://pastebin.com/CWWqdT0i
Please can someone either tell me what I've done wrong or advise me on how
to find out more information about the weird error. This is the first time
I've had to handle an auto-identity column and also the first time I've had
to process a result set from a stored procedure within RPG.
The o/s version is 7.1. All source, programs and files are on the same
partition
Thanks in advance,
-Paul.
PS I can also reproduce the same error if I call the SP twice from ACS' Run
SQL Scripts using "call C_EVENT(23, varchar('Test1',100), 'Y');"
As an Amazon Associate we earn from qualifying purchases.