1

I wrote the below trigger to prevent users from allocating a Class to a Session if the Class Date does not match the day of the week the Session is on.

CREATE OR REPLACE TRIGGER trig_alternative_classDate
AFTER INSERT OR UPDATE ON ALTERNATIVE
FOR EACH ROW
DECLARE
    classdate CHAR;
    sessionday VARCHAR;
BEGIN
    SELECT to_char(to_date(class.class_date), 'Day') INTO classdate, sessions.day INTO sessionday
    FROM SESSIONS, CLASS, DUAL, LOCATION, ALTERNATIVE
    WHERE class.class_id = alternative.class_id
    AND alternative.location_id = location.location_id
    AND sessions.location_id = location.location_id;
    IF sessions.day != to_char(to_date(class.class_date), 'Day')
    THEN raise_application_error(-20999,'Invalid Class Date - Class Date does not match Session Day');
    END IF;
END;
/

However I get an error message when I run the trigger

Warning: Trigger created with compilation errors.

SQL> show error trigger trig_alternative_classDate
Errors for TRIGGER TRIG_ALTERNATIVE_CLASSDATE:

LINE/COL ERROR
-------- -----------------------------------------------------------------
5/2  PL/SQL: SQL Statement ignored
5/80 PL/SQL: ORA-00923: FROM keyword not found where expected

Could someone please help?

1 Answer 1

2

Remove second INTO - only one INTO is needed:

INTO classdate, sessions.day INTO sessionday
Sign up to request clarification or add additional context in comments.

1 Comment

@Ben Townsend - Did you try? Works?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.