case on postgresql to insert/update table -
i using simple case condition insert or update on postgresql didnt know why when insert insert/update each condition got error..
this simple function:
create or replace function insert_new_table_log() returns trigger $new_table$ begin select id_hdr, case id_hdr when id_hdr = old.id (update new_table_dtl set id_hdr = old.id, nama = old.nama, description=old.description id_hdr = old.id) else (insert new_table_dtl(id_hdr, nama, description) values(old.id, old.nama, old.description)) end new_table_dtl; return new; end; $new_table$ language plpgsql;
and message error
error: syntax error @ or near "new_table_dtl" line 7: (update new_table_dtl set id_hdr = old.id, nama = old.na...