There is a table:
CREATE TABLE my_table ( name VARCHAR2(20 BYTE) NOT NULL, car VARCHAR2(40 BYTE) NOT NULL, rank NUMBER, PRIMARY KEY (name, car) ); In Java, I have a List - objects that store information name, car, rank = null.
You need to write a stored function (pl / sql) that implements the following:
If there are objects in the List that are not in the table, add them to the table.
If there are no records in the List that are in the table, remove them from the table.
In these operations, do not take into account the rank field (ie, when comparing without a difference in its value).
I only thought of this:
DECLARE type my_table_array IS TABLE OF my_table%ROWTYPE; v_Numbers my_table_array := my_table_array(); rec my_table%ROWTYPE; idx number; BEGIN v_Numbers.extend(1); idx := v_Numbers.count; rec.name := 'John'; rec.car := 'Toyota'; rec.rank := 5; v_Numbers(idx) := rec; END; How is it nice to check in BEGIN now? If there are no such records in the table, add. And run through all v_Numbers.
merge- Viktorov