使用 Select 查找数据表中的重复数据
我需要一些帮助。
我正在从 Excel 文件读取一些数据,需要将其插入到 Oracle 表中。 好的,但在插入之前我必须做一些验证。
之前这样做的人在插入后进行了验证。我正在将其更改为之前执行此操作,因为插入大量数据需要花费一些时间。
这是验证它的当前方法:
SELECT FV, COD_BRICK, CANAL, SEGMENTO
FROM TJANSSEN_MATRIZ_DDD_SEGMENTO
WHERE (FV, COD_BRICK, CANAL, SEGMENTO) IN
(SELECT FV, COD_BRICK, CANAL, SEGMENTO
FROM TJANSSEN_MATRIZ_DDD_SEGMENTO
GROUP BY FV, COD_BRICK, CANAL, SEGMENTO
HAVING COUNT(*) > 1)
ORDER BY FV, COD_BRICK, CANAL, SEGMENTO;
如果返回某些内容,则存在重复的内容,我应该警告或给出一些错误。
无论如何,我不知道如何使用 Datatable 的 Select() 方法来执行此操作。我的意思是,我有时已经使用过它,但表达方式很简单。
感谢您的阅读和帮助。
dev_加布里埃尔(:
I need some help on something.
I am reading some data from an Excel file and I need to insert it into an Oracle table.
Ok, but before inserting it i gotta do some validations.
The guy that did this before did the validations AFTER inserting. I am changing it to do it before 'cause it's an ammount of data that takes sometime to be inserted.
Here is the current way of validating it:
SELECT FV, COD_BRICK, CANAL, SEGMENTO
FROM TJANSSEN_MATRIZ_DDD_SEGMENTO
WHERE (FV, COD_BRICK, CANAL, SEGMENTO) IN
(SELECT FV, COD_BRICK, CANAL, SEGMENTO
FROM TJANSSEN_MATRIZ_DDD_SEGMENTO
GROUP BY FV, COD_BRICK, CANAL, SEGMENTO
HAVING COUNT(*) > 1)
ORDER BY FV, COD_BRICK, CANAL, SEGMENTO;
If this returns something, then there is duplicated stuff and I should warn or give some error.
Anyway, I don't know exactly how to do this using Datatable's Select() method. I mean, I alredy used it sometimes but with simple expressions.
Thanks for reading and for your help.
dev_Gabriel (:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该以最高效的方式执行此操作的方法是:
The way you should do this in the most performant manner is to: