How can I write a sequence and trigger that upon insert into a table will check if the ID attribute (and INTEGER) is null.
If null it should increment through from 1 upwards checking if the value itself if already a primary key and if not that should use that as the primary key to insert.
Otherwise if id is not null it should update the row at the id given
I have this so far but am not sure about it
CREATE SEQUENCE create_student_id
START WITH 1
INCREMENT BY 1;
CREATE OR REPLACE TRIGGER new_student_id BEFORE
INSERT ON orders
    IF StudentID == null
    THEN
        FOR EACH ROW BEGIN
            :new.StudentID := create_student_id.nextval;
    END IF
--Need to update the table otherwise
    END;