× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Here are a few potential causes fo this issue:

1. Incorrect SQL statement: Verify that your SQL statement is correct and compatible with the database you are using. Ensure that the table and column names are accurate and that the statement performs the intended update or insert operations.

2. Invalid parameter values: Check that the parameter values you are passing in the SqlParameterSource objects are valid and appropriate for the corresponding columns in the table. Make sure the data types match and there are no null or unexpected values.

3. Constraint violations: If your SQL statement includes constraints (such as unique key constraints), it's possible that some of the rows in your batch violate these constraints. Review your data and ensure that you are not attempting to insert duplicate or conflicting values.

4. Database connectivity issues: It's worth verifying that you have a stable connection to the database and that there are no network or access-related problems that could prevent the batch update from executing correctly.

To further investigate the issue, you should check the specific error or exception message that accompanies the -2 return values. This information can help pinpoint the exact cause of the problem. Additionally, reviewing the logs or error messages from the database system might provide valuable insights into the issue.

Regards.
Augusto Sepulveda Bilbao

De: David Gibbs via JAVA400-L<mailto:java400-l@xxxxxxxxxxxxxxxxxx>
Enviado: lunes, 26 de junio de 2023 1:47 p. m.
Para: java400-l@xxxxxxxxxxxxxxxxxx<mailto:java400-l@xxxxxxxxxxxxxxxxxx>
CC: David Gibbs<mailto:david@xxxxxxxxxxxx>
Asunto: Spring batchUpdate vs. update?

Folks:

I’m not sure if this issue is due to Spring framework or JT400.

I’ve got a merge statement that I’m running to do an ‘upsert’ operation.

----------
MERGE INTO file R
USING (values(:field1,:field2,:field3,:field4,:field5,
:field6,:field7))
AS N (field1,field2,field3,field4, field5,field6,field7)
ON (r.field1,r.field5) = (n.field1,n.field5)
WHEN MATCHED THEN
UPDATE SET (field2,field3,field4,field6,field7) =
(:field2,:field3,:field4,:field6,:field7)
WHEN NOT MATCHED THEN
INSERT (field1,field2,field3,field4, field5,field6,field7)
values(:field1,:field2,:field3,:field4,:field5, :field6,:field7)
—————

I’m processing the data in a batch, so I’m building an array of SqlParameterSource objects and then running batchUpdate on a NamedParameterJdbcTemplate object.

The return value I get back is an array of -2’s.

This indicates that the update operation could not determine the number of rows updated (I’m assuming via returned metadata). The data in the table is always updated correctly.

However, if I execute the update multiple times using the update method, I always get a return value of 1.

I would like to verify that the correct number of records were inserted or updated.

Any suggestions on where to look in order to get the correct number of records updated?

Thanks!

David


IBM i on Power Systems: For when you can't afford to be out of business!

I'm riding a in the American Diabetes Association's Tour de Cure to raise money for diabetes research, education, advocacy, and awareness. You can make a tax deductible donation to my ride by visiting https://mideml.diabetessucks.net. My goal is $7000 but any amount is appreciated.

You can see where my donations come from by visiting my interactive donation map ... https://mideml.diabetessucks.net/map (it's a geeky thing).

I may have diabetes, but diabetes doesn't have me!

--
This is the Java Programming on and around the IBM i (JAVA400-L) mailing list
To post a message email: JAVA400-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/java400-l
or email: JAVA400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/java400-l.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

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.