I need to insert some rows to tables in PostgreSQL. But before inserting the row into table, I should check whether the record is existing or not by using update statement. If update statement returns 0 rows, then I can insert, otherwise I can skip that insertion. I should write SQL statements for this in .sql file in PostgreSQL.
How to achieve this?
In Oracle we have below format:
declare
i number;
begin
update employees set status = 'fired' where name like '%Bloggs';
i := sql%rowcount;
IF i ==0 THEN
insert statement here
end
How can I achieve this in Postgres?