In SQL, I created 2 user types. The first is just a minimal type, for a brief example.
CREATE OR REPLACE TYPE TestType FORCE AS OBJECT
(
title VARCHAR(50)
);
/
The second type is the log type of the first type. This type is used to record changes of the first type.
CREATE OR REPLACE TYPE LogType FORCE AS OBJECT
(
title VARCHAR(50),
TestRef REF TestType
);
/
And tables:
CREATE TABLE TestTable OF TestType;
CREATE TABLE LogTable OF LogType;
Trigger:
CREATE TRIGGER UpdateLog
BEFORE UPDATE OF title ON TestTable
REFERENCING new as newrow old as oldrow
FOR EACH ROW
WHEN (newrow.title != oldrow.title)
BEGIN
INSERT INTO LogTable VALUES(:oldrow.title, :newrow);
END UpdateLog;
/
Now, as mentioned earlier, I would like to have a trigger on TestTable that will monitor row changes. The next part works, the problem occurs when I want to insert changes into the log table. Inserting zero instead of help works, but trying to insert something similar: newrow or ref (: newrow) does not. It throws an invalid bind variable (PLS-00049).
So the question is, how do I reference newrow in the log table?