#1
  1. No Profile Picture
    almost there....
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Location
    A Red Glitter Coffin
    Posts
    140
    Rep Power
    0

    Trigger Compilation Error


    Having some trouble trying to figure out this compilation error, can anyone help?

    CREATE OR REPLACE TRIGGER match_gender_check
    BEFORE INSERT OR UPDATE ON matches
    FOR EACH ROW
    BEGIN
    DECLARE
    homegender VARCHAR(1);
    oppgender VARCHAR(1);

    BEGIN
    SELECT h.teamgender INTO homegender FROM hometeams h WHERE :new.hometeam = REF(h);
    SELECT o.teamgender INTO oppgender FROM opponentteams o WHERE :new.opponent = REF(o);
    END


    IF(homegender != oppgender) THEN
    RAISE_APPLICATION_ERROR(-20012, 'Teams Of Opposite Gender Cannot Play Against Each Other');
    END;
    /

    Thanks!
  2. #2
  3. No Profile Picture
    almost there....
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Location
    A Red Glitter Coffin
    Posts
    140
    Rep Power
    0
    Never mind i got it. Here's the corrected version in case some lost fool is searching for it in future:

    CREATE OR REPLACE TRIGGER match_gender_check
    BEFORE INSERT OR UPDATE ON matches
    FOR EACH ROW
    DECLARE
    homegender VARCHAR(1);
    oppgender VARCHAR(1);

    BEGIN
    SELECT h.teamgender INTO homegender FROM hometeams h WHERE :new.hometeam = REF(h);
    SELECT o.teamgender INTO oppgender FROM opponentteams o WHERE :new.opponent = REF(o);


    IF(homegender != oppgender) THEN
    RAISE_APPLICATION_ERROR(-20012, 'Boys Are Better Than Girls. Its Just Not Fair.');
    END IF;
    END;

IMN logo majestic logo threadwatch logo seochat tools logo