This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE OR REPLACE FUNCTION | |
record_inventory_change() | |
RETURNS TRIGGER LANGUAGE plpgsql AS $$ | |
DECLARE | |
columns text; | |
entity RECORD := NEW; | |
_deleted VARCHAR(5) := 'false'; | |
BEGIN | |
SELECT string_agg(column_name, ',') INTO columns from information_schema.columns where table_name = 'inventory'; | |
IF TG_OP = 'DELETE' THEN |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TRIGGER test_trigger_insert_update AFTER UPDATE OR INSERT ON inventory FOR EACH ROW EXECUTE PROCEDURE record_inventory_change(); | |
CREATE TRIGGER test_trigger_delete BEFORE DELETE ON inventory FOR EACH ROW EXECUTE PROCEDURE record_inventory_change(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data class Animal( | |
val name: String | |
) | |
data class Farm( | |
val animals: List<Animal> = emptyList(), | |
) |
OlderNewer