我有一个Oracle查询,正在尝试使用jdbc执行.以下是查询.
I have an oracle query which i am trying to execute using jdbc. Following is the query.
insert into bd_vehicles_temp select * from bd_vehicles_temp_1表bd_vehicles_temp_1包含大约7000-10000行.如果bd_vehicles_temp_1中已经存在bd_vehicles_temp_1中的主键,则会得到一个SQLException:唯一键约束.
table bd_vehicles_temp_1 contains about 7000-10000 rows. If a primary key in bd_vehicles_temp_1 is already present in bd_vehicles_temp i get an SQLException : Unique key constraint.
在我的代码中,例外行是偏离路线pstmt.executeUpdate().有没有一种方法可以精确定位bd_vehicles_temp_1中导致异常的行.
the line of exception is offcourse pstmt.executeUpdate() in my code. Is there a way to pinpoint the row in bd_vehicles_temp_1 which causes exception.
还是我必须遍历bd_vehicles_temp_1中的行并逐行插入每一行?
Or do i have to do loop through rows in bd_vehicles_temp_1 and insert each row one by one ?
预先感谢!
推荐答案如果您知道会导致异常的列,则可以使用(特定于Oracle)
If you know the column that can cause the exception you can use (Oracle specific)
SELECT col FROM bd_vehicles_temp INTERSECT SELECT col FROM bd_vehicles_temp_1;标识两个表中的所有行.
to identify all rows that are in both tables.
更多推荐
Oracle JDBC:如何知道哪一行引发唯一键约束?
发布评论