In the history table, I wanted to add all values of column3 IF they have the same column2 value which is 12345. And if the sum of that equates to 0, then their column1 would be change to 16977.
Using this code:
UPDATE history
SET column1 = 16977
WHERE
(SELECT SUM(column3)FROM history WHERE column2 = 12345) = 0
AND column2 = 12345;
I got the following error:
Error report -
SQL Error: ORA-08002: sequence SEQLOG.CURRVAL is not yet defined in this session ORA-06512: at "MCM_2017.GETUSERID", line 8 ORA-06512: at "MCM_2017.GET_MVT", line 103 ORA-04088: error during execution of trigger 'MCM_2017.GET_MVT' 08002. 00000 - "sequence %s.CURRVAL is not yet defined in this session" *Cause: sequence CURRVAL has been selected before sequence NEXTVAL *Action: select NEXTVAL from the sequence before selecting CURRVAL
I tried using another code using IF statement:
DECLARE
total: NUMBER;
BEGIN
SELECT SUM(column3) INTO total FROM history WHERE column2 = 12345;
IF total = 0 THEN
UPDATE history
SET column1 = 16977
WHERE column2 = 12345;
END IF;
END;
But I ended up with another error:
Error report - Missing IN or OUT parameter at index:: 1
Please help me on this one, I'm really stuck