how to update records else insert records in postgresql How to perform update and insert in same query? i need to update the record, if it is not present then it has to perform insertion i tried this 

UPDATE bank SET  Address= $2,"PANCard"= $3,"IFSC" = $4  WHERE user_id = $1;
INSERT INTO bank (user_id,bank_details,"PAN",bank_acc,"UAN",tax)
       SELECT  '$2','$3','$4','$5','$6'
       WHERE NOT EXISTS (SELECT * FROM bank WHERE user_id=$1);


but am getting 

{
  "name": "error",
  "length": 123,
  "severity": "ERROR",
  "code": "42601",
  "file": "postgres.c",
  "line": "1274",
  "routine": "exec_parse_message"
}


please help me here
You can use the UPSERT:

https://www.postgresql.org/docs/9.5/static/sql-insert.html

Example from documentation: 

INSERT INTO distributors (did, dname)
VALUES (5, 'Gizmo Transglobal'), (6, 'Associated Computing, Inc')
ON CONFLICT (did) DO UPDATE SET dname = EXCLUDED.dname;