Hello everyone, I am having a problem that I could not resolve. When I insert tuples in a table and call test, I am having the problems. But I do not want to insert a tuple since because it is already in the test database. I also could not use distinct in SELECT because I have to check each tuple. The DECLARE section is declared and so not to worry.
Code:
BEGIN
Open c1;
FETCH c1 INTO read_nameusu, read_namepat, read_prename, read_dtenai, read_depcol, read_worddep;
co_nameusu := read_nameusu;
co_namepat := read_namepat;
co_prenname := read_prename;
co_dtenai := read_dtenai;
co_depcol := read_depcol;
co_worddep := read_worddep;
LOOP
FETCH c1 INTO read_nameusu, read_namepat, read_prename, read_dtenai, read_depcol, read_worddep;
IF read_namepat = co_namepat AND read_prename = co_prename AND read_dtenai = co_dtenai THEN
IF read_depcol IS NULL AND co_depcol IS NULL THEN
INSERT INTO ANOMALY VALUES
(
read_nameusu, read_namepat, read_prename, read_dtenai, read_depcol, read_worddep
);
INSERT INTO ANOMALY VALUES
(
co_nameusu, co_namepat, co_prename, co_dtenai, co_depcol, co_worddep
);
END IF;
IF read_depcol IS NULL THEN
ins_nameusu := read_nameusu;
ins_namepat := read_namepat;
ins_prename := read_prename;
ins_dtenai := read_dtenai;
ins_depcol := read_depcol;
ins_worddep := read_worddep;
ELSE
IF read_depcol > co_depcol AND co_depcol IS NOT NULL THEN
ins_nameusu := read_nameusu;
ins_namepat := read_namepat;
ins_prename := read_prename;
ins_dtenai := read_dtenai;
ins_depcol := read_depcol;
ins_worddep := read_worddep;
END IF;
END IF;
ELSE
IF /* If not in table */ THEN
INSERT INTO ATime VALUES
(
ins_nameusu, ins_namepat, ins_prename, ins_dtenai, ins_depcol, ins_worddep
);
END IF;
END IF;
co_nameusu := read_nameusu;
co_namepat := read_namepat;
co_prename := read_prename;
co_dtenai := read_dtenai;
co_depcol := read_depcol;
co_worddep := read_worddep;
EXIT WHEN c1%NOTFOUND;
END LOOP;
CLOSE c1;
END;
Bookmarks