I need to update a field on a different table if the current table that is declared on the trigger gets updated. But I need to update only after 2 conditions
public class Match{
public int participant1;
public int participant2;
public int winner;
public boolean finalMatch;
public int standingId;
}
public class Standings{
public int id;
public int firstPlace;
public int SecondPlace;
}
private static final String CREATE_TRIGGER_MATCH_UPDATE_BRACKET_WINNERS_F1 = "CREATE TRIGGER if not exists updatefields
AFTER UPDATE OF winner
ON Match
WHEN new.finalMatch = 1 AND new.winner = new.participant1
BEGIN
UPDATE Standings
SET firstPlace = new.winner
SecondPlace = new.participant2
WHERE id = new.standingId
END;"
But this throws an error. Apparently there can only be on "WHEN condition" for triggers on android. Now I'm not really sure how to go about checking it. As I would like to do this update of the two fields on one trigger. If I do two triggers, 1 for the setting up of "firstPlace" and another for the "secondPlace", the second one will be on the Standings table and I'm not really sure how to get access to that "secondPlace" value.
Aucun commentaire:
Enregistrer un commentaire