When running import in batch mode, ADS never takes failure transaction count into consideration upon calculating number of successfully inserted rows. The attached screenshot is based on the test data file used by issue #8757, see issue #8757 for more info.
FYI: java.sql.Statement.executeBatch() should return an int[]. If exception is thrown by executeBatch(), that exception is likely a BatchUpdateException. You can get int[] by calling BatchUpdateException.getUpdateCounts(). See java doc for more info on the returned int[].
|
131 KB
|
92 KB
![]() |
442 B
I created below table in Sybase ASE and then imported using the attached file. After import ADS displayed inserted 54 rows successfully, when I did a select * 0 rows was inserted. Hence, row count is incorrect
CREATE TABLE dbo.i9021 (
a varchar(25) NOT NULL,
b varchar(25) NOT NULL,
c varchar(25) NOT NULL,
d varchar(25) NOT NULL,
CONSTRAINT s PRIMARY KEY CLUSTERED(a)
WITH max_rows_per_page = 0, reservepagegap = 0
)
LOCK ALLPAGES
GO
I created below table in Sybase ASE and then imported using the attached file. After import ADS displayed inserted 54 rows successfully, when I did a select * 0 rows was inserted. Hence, row count is incorrect
CREATE TABLE dbo.i9021 (
a varchar(25) NOT NULL,
b varchar(25) NOT NULL,
c varchar(25) NOT NULL,
d varchar(25) NOT NULL,
CONSTRAINT s PRIMARY KEY CLUSTERED(a)
WITH max_rows_per_page = 0, reservepagegap = 0
)
LOCK ALLPAGES
GO
When an error occurs for Sybase BCP Import, preparedStmt.executeBatch() throws SQLException instead of BatchUpdateException. Fixed the inserted count by checking preparedStmt.getUpdateCount() in this case.
When an error occurs for Sybase BCP Import, preparedStmt.executeBatch() throws SQLException instead of BatchUpdateException. Fixed the inserted count by checking preparedStmt.getUpdateCount() in this case.
One observation with Sybase BCP Import:
- For Sybase ASE, if one record in a batch of 500 fails, none of the record is inserted.
- For Sybase IQ with iAnywhere Driver, if one record in a batch of 500 fails, the other 499 records are still inserted.
One observation with Sybase BCP Import:
- For Sybase ASE, if one record in a batch of 500 fails, none of the record is inserted.
- For Sybase IQ with iAnywhere Driver, if one record in a batch of 500 fails, the other 499 records are still inserted.
With the same table and file, I attached, the final row count is 1 less than the original value. Can, you look into this in 14.0.0-beta-74 ?
With the same table and file, I attached, the final row count is 1 less than the original value. Can, you look into this in 14.0.0-beta-74 ?
I can reproduce the problem using batch import (not BCP import) and choose "first row contains column names" option.
Let's look at the first 10 lines of your data file.
When the "first row contains column names" option is checked, the first row is not considered as data. It looks like 3 records get inserted, but BatchUpdateException.getUpdateCounts() returns 2 elements only.
f,g,h,i <-- column names, not imported
j,k,l,m <-- success
a,b,c,d <-- success
j,k,l,m <-- error, duplicate
a,b,c,d <-- error, duplicate
f,g,h,i <-- success (select query shows that this record gets inserted)
j,k,l,m
a,b,c,d
f,g,h,i
j,k,l,m
When the "first row contains column names" option is not checked, the first row is imported. In this case, the first 3 records get inserted and BatchUpdateException.getUpdateCounts() returns 3 elements correctly.
f,g,h,i <-- success
j,k,l,m <-- success
a,b,c,d <-- success
j,k,l,m <-- error, duplicate
a,b,c,d <-- error, duplicate
f,g,h,i <-- error, duplicate
j,k,l,m
a,b,c,d
f,g,h,i
j,k,l,m
There is a bug with BatchUpdateException -- Sybase bug, not ours.
I can reproduce the problem using batch import (not BCP import) and choose "first row contains column names" option.
Let's look at the first 10 lines of your data file.
When the "first row contains column names" option is checked, the first row is not considered as data. It looks like 3 records get inserted, but BatchUpdateException.getUpdateCounts() returns 2 elements only.
f,g,h,i <-- column names, not imported
j,k,l,m <-- success
a,b,c,d <-- success
j,k,l,m <-- error, duplicate
a,b,c,d <-- error, duplicate
f,g,h,i <-- success (select query shows that this record gets inserted)
j,k,l,m
a,b,c,d
f,g,h,i
j,k,l,m
When the "first row contains column names" option is not checked, the first row is imported. In this case, the first 3 records get inserted and BatchUpdateException.getUpdateCounts() returns 3 elements correctly.
f,g,h,i <-- success
j,k,l,m <-- success
a,b,c,d <-- success
j,k,l,m <-- error, duplicate
a,b,c,d <-- error, duplicate
f,g,h,i <-- error, duplicate
j,k,l,m
a,b,c,d
f,g,h,i
j,k,l,m
There is a bug with BatchUpdateException -- Sybase bug, not ours.
Issue #9021 |
Closed |
Fixed |
Resolved |
Completion |
No due date |
Fixed Build ADS 14.0.0-beta-74 |
No time estimate |
5 issue links |
relates to #8757
Issue #8757Commit failed: Type '7' not implemented Error in ASE |
relates to #9697
Issue #9697Bug with BatchUpdateException for Batch Import - gives incorrect # of rows inserted |
relates to #9292
Issue #9292Import not working for Sybase ASE |
relates to #8799
Issue #8799Failed to insert data when data is more then the specified length |
relates to #9689
Issue #9689Incorrect Inserted rows in Cassandra Import Tool |
Now the final inserted row counts should match the number of imported rows.