简体   繁体   English

使用游标更新大量数据的问题

[英]Problem with large numbers of data update with cursor

I wrote a query. 我写了一个查询。 I am editing data from a registered table of about 37000 and updating it with a cursor. 我正在编辑大约37000的注册表中的数据并用光标更新它。 It goes wrong result when I exceed a certain number. 当我超过一定数量时,它会出错。 This record count is about 12800-12900. 此记录数约为12800-12900。

Does anyone have any idea why this is happening? 有谁知道为什么会这样? I'm so confused. 我很混乱。

Is there any possibility of a restriction when working with the cursor? 使用光标时是否有任何限制?

BelgeNo = DocumentNo
CoKey = Company's unique number
Kapsam = type of document
Durumu = status (for document valid=1 invalid=0)
BitisTarihi = End date of the document

Original table has about 37000 records and mixed. 原始表有大约37000条记录和混合。 I tried to group for 'CoKey' and 'Kapsam' the data in the original table with the following query. 我尝试使用以下查询将原始表中的数据分组为“CoKey”和“Kapsam”。

SELECT A.ID, A.BelgeNo, A.CoKey, A.Kapsam, A.Durumu, A.BitisTarihi
FROM Sshyb A
INNER JOIN (SELECT CoKey, Kapsam
            FROM Sshyb
            GROUP BY CoKey, Kapsam
            HAVING COUNT(*) > 1) B
ON A.CoKey = B.CoKey AND A.Kapsam = B.Kapsam
ORDER BY A.Kapsam, A.CoKey

But I may be making a mistake in this query. 但我可能在这个查询中犯了一个错误。 The number of records is about 25000 when the query runs coz of 'having'. 当查询运行'have'时,记录数约为25000。 (i have to do this for single records) anyway (无论如何,我必须为单个记录执行此操作)

Table: ibb.co/5YmPPDH 表:ibb.co/5YmPPDH

After that i have cases: 之后我有案例:

if CoKey = Kapsam

biggest 'end date' must be true, others must be false (in the group as selected in the picture)

if dates are before today all should be wrong in the group

if CoKey != Kapsam

Switch to other group and check same case

In order to do this, I use the cursor as in the query. 为此,我在查询中使用光标。 I am trying to find the groups with the temporary table and update the above. 我试图找到临时表的组并更新上述内容。 But when it goes above about 12000 records, the update process does not work as I designed it. 但当它超过大约12000条记录时,更新过程不能像我设计的那样工作。 I am not receiving an error but the update is incorrect. 我没有收到错误,但更新不正确。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM