Ich möchte TOTAL_DURATION
von dem Wert in Spalte aktualisieren Tabelle IAM_RSP_INSTRUCTION
, wobei der Wert von TOTAL_DURATION
auf der Abfrage basiertUpdate-Spalte mit Daten aus mehreren Tabellen
select (paid_rsp + rd) as total from
(
select count (b.rsp_instruction_id) as paid_rsp, a.rsp_duration as rd,
b.rsp_instruction_id
from IAM_RSP_INSTRUCTION a
JOIN IAM_BUY_FUND_INFO b on a.RSP_ID = b.RSP_INSTRUCTION_ID
where b.RSP_INSTRUCTION_ID is not null
and a.rsp_status= 'approved' or a.rsp_status='terminated'
group by a.rsp_duration, b.rsp_instruction_id, a.rsp_status<br>
HAVING a.rsp_duration > -1
order by b.rsp_instruction_id
) ,
and rsp_id from IAM_RSP_INSTRUCTION = rsp_instruction_id
from IAM_BUY_FUND_INFO
Derzeit habe ich eine Aktualisierungsabfrage:
UPDATE IAM_RSP_INSTRUCTION
SET j.TOTAL_DURATION = (
select (paid_rsp + rd) as total
from (
select count (b.rsp_instruction_id) as paid_rsp, a.rsp_duration as rd,
b.rsp_instruction_id
from iam_rsp_instruction a
JOIN iam_buy_fund_info b on a.RSP_ID = b.RSP_INSTRUCTION_ID
where b.RSP_INSTRUCTION_ID is not null
and a.rsp_status= 'approved' or a.rsp_status='terminated'
group by a.rsp_duration, b.rsp_instruction_id, a.rsp_status
HAVING a.rsp_duration > -1
order by b.rsp_instruction_id
)
WHERE IAM_RSP_INSTRUCTION.rsp_id = rsp_instruction_id
);
Wenn ich die Abfrage nach 8 Stunden ausführen, läuft es noch und keine Datensätze aktualisiert werden.
Hinweis: Die Unterabfrage hat funktioniert, als ich sie ausgeführt habe.
select (paid_rsp + rd) as total from
(
select count (b.rsp_instruction_id) as paid_rsp, a.rsp_duration as rd,
b.rsp_instruction_id
from IAM_RSP_INSTRUCTION a
JOIN IAM_BUY_FUND_INFO b on a.RSP_ID = b.RSP_INSTRUCTION_ID
where b.RSP_INSTRUCTION_ID is not null
and a.rsp_status= 'approved' or a.rsp_status='terminated'
group by a.rsp_duration, b.rsp_instruction_id, a.rsp_status<br>
HAVING a.rsp_duration > -1
order by b.rsp_instruction_id
)
Bitte helfen. Vielen Dank.
Welche DBMS verwenden Sie? sql srver <> oracle. Und Sie müssen "nicht funktionieren" definieren. –
Bitte senden Sie die Fehlermeldung. –
Lassen Sie Ihre Anfrage zuerst bearbeiten und dann herausfinden, wie Sie sie im Update verwenden. Sie müssen die Daten aus der Tabelle, die Sie aktualisieren, mit der von Ihnen verwendeten Unterabfrage korrelieren. –