I have two tables, doc (in a database1) and docs (in a database2). With the below key fields:
doc: KEY,OLD_KEY
docs: RKEY
Now doc.OLD_KEY = docs.RKEY. I am working on checking where doc.OLD_KEY = docs.RKEY and set docs.RKEY = doc.KEY.
I have written the below syntax, however it i am not being able to successfully run for i haven't worked with for loop before.
DECLARE
OLD_KEY_var NUMBER(10);
KEY_var NUMBER(38);
BEGIN
FOR dc.KEY IN (
SELECT dc.KEY,dc.OLD_KEY INTO KEY_var,OLD_KEY_var
FROM user.database2 docs,database1 dc
where docs.RKEY=dc.OLD_KEY
) LOOP
UPDATE user.database2 docs SET docs.RKEY = KEY_var where docs.RKEY=OLD_KEY_var;
END LOOP;
END;
I have a connexion and grant priviliges between the tables, and i am getting