Referensi
- Five ways to paginate in Postgres, from the basic to the exotic, https://www.citusdata.com/blog/2016/03/30/five-ways-to-paginate/
CREATE OR REPLACE FUNCTION soal_set_status_akhir()
RETURNS TRIGGER
AS $$
BEGIN
NEW.status_akhir := CASE WHEN NEW.id_status_soal = 1 THEN 1
ELSE 0 END;
RETURN NEW;
END $$ LANGUAGE plpgsql;
DROP TRIGGER IF EXISTS soal_set_status_akhir ON soal;
CREATE TRIGGER soal_set_status_akhir
BEFORE INSERT OR UPDATE ON soal
FOR EACH ROW
EXECUTE PROCEDURE soal_set_status_akhir();