I will using simple case condition to insert or update on Postgresql but I didnt know why when i insert insert/update for each condition I got error..
This is my simple function:
CREATE OR REPLACE FUNCTION insert_new_table_log() RETURNS TRIGGER AS $new_table$
BEGIN
SELECT id_hdr,
    CASE id_hdr
        WHEN id_hdr = OLD.id
            THEN 
            (UPDATE new_table_dtl 
             SET id_hdr = OLD.id, nama = OLD.nama,
                 description=OLD.description 
             WHERE id_hdr = OLD.id)
        ELSE
            (INSERT INTO new_table_dtl(id_hdr, nama, description) 
             values(OLD.id, OLD.nama, OLD.description))
    END
    FROM new_table_dtl;
RETURN NEW; 
END;
$new_table$ LANGUAGE plpgsql;
and this is message error
ERROR: syntax error at or near "new_table_dtl" LINE 7: (UPDATE new_table_dtl SET id_hdr = OLD.id, nama = OLD.na...
 
    