Hi. It is a bad idea to use the REPLACE INTO sql syntax, because this is mysql only. It will not work in postgresql. Also, I am using Oracle as my database backend, and REPLACE INTO doesn't work there either.

These should be replaced with INSERT and UPDATE queries.