Postgres triggers

Поделиться
HTML-код
  • Опубликовано: 3 ноя 2024

Комментарии • 10

  • @Faycal59
    @Faycal59 9 дней назад

    Thank you

  • @larisastefan1259
    @larisastefan1259 Год назад

    Thank you so much! Very useful!

  • @mihirpande8786
    @mihirpande8786 2 года назад

    exactly what i needed , thank you very much

  • @sunbox9383
    @sunbox9383 3 года назад +1

    This really helped. Thank you!

  • @PaperPalette_
    @PaperPalette_ 3 года назад

    i was looking for this , clear explanation, thank you!!!!

  • @rujor
    @rujor 4 года назад +1

    Exactly what I needed--thanks 👏!

  • @vipinn6981
    @vipinn6981 3 года назад

    thank you clear explanation.

  • @nassehk
    @nassehk 2 года назад

    For me using postgres13, I have to return new for update to happen. Otherwise despite the insert to archive working, the record will stay as it was.

    • @nassehk
      @nassehk 2 года назад

      I forgot to thank you for the great tutorial you have made. I wish you could do another shorter one with faster pace.

  • @kunyuchang
    @kunyuchang 2 года назад +1

    CREATE FUNCTION ar_artist()
    RETURNS trigger AS
    $$
    BEGIN
    INSERT INTO archive_artist (artistid, name)
    VALUES (OLD.artistid, OLD.name);
    RETURN OLD;
    END;
    $$
    LANGUAGE 'plpgsql';

    CREATE TRIGGER archiveArtist
    BEFORE DELETE ON artist
    FOR EACH ROW
    EXECUTE PROCEDURE ar_artist();