Identity columns are populated automatically when you do an insert.
Going under the assumption that "Id" is you identity column, all you
need to do is remove that from your insert statement and you'll be good
to go. BTW, this topic is covered pretty well in the SQL books.
Matt
-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Nick Arndt
Sent: Thursday, October 04, 2007 12:26 PM
To: RPG programming on the AS400 / iSeries
Subject: Inserting records into SQL server data base
Hi all,
I am getting the following error when I try to insert records into a sql
server database file
RNX0301 Escape 50 10/04/07 11:08:23.184696
QRNXIE QSYS *STMT JDBCR4 ARNDT3 *STMT
From module . . . . . . . . :
QRNXMSG
From procedure . . . . . . :
SignalException
Statement . . . . . . . . . :
20
To module . . . . . . . . . :
JDBCR4
To procedure . . . . . . . :
JDBC_EXECPREPUPD
Statement . . . . . . . . . :
2925
Message . . . . : Java exception
received when calling Java method.
Cause . . . . . : RPG procedure
JDBC_EXECP in program ARNDT3/JDBCR4 received
Java exception "
com.microsoft.sqlserver.jdbc.SQLServerException: Cannot
insert explicit value for
identity
column in" when calling method
"executeUpdate" with signature
"()I"
in class "java.sql.PreparedStatement".
Recovery . . . : Contact the
person responsible for program maintenance
to determine the cause of the
problem. Technical description . . . . . . . .
: If the exception indicates
that
the Java class was not found, ensure the
class for the method is in the
class
path. If the exception indicates that
the Java method was not found,
check
the method name and signature. If the
signature is not correct, change
the
RPG prototype for the method, or change
the Java method, so that the
return
type and parameter types match. You can
determine the signatures for all
the
methods in class XYZ using command QSH
CMD('javap -s
XYZ').
// set values to be inserted into file
JDBC_setDecimal(stmt:1:clientds.RECID);
JDBC_setString(stmt:2:Clientds.CLIENTID);
JDBC_SetString(stmt:3:clientds.CLIENTNAME);
JDBC_SetString(stmt:4:clientds.CLINTCNTRY);
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact
[javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.