pg - Upsert in Postgres Ruby -
i have seen other questions deal issue , know postgresql doesn't have inbuilt upsert , must done using 2 methods. code i'm using in ruby using pg gem.
@db.exec_params("update crawled set url = $1, timestamp = $2 url = $1",[url,datetime.now]) @db.exec_params("insert crawled (url, timestamp) values ($1, $2) not exists (select 1 crawled url = $1)",[url,datetime.now])
however when run syntax error
exec_params': error: syntax error @ or near "where" (pg::error) line 1: ...ert crawled (url, timestamp) values ($1, $2) not ...
where mistake?
just looking @ example have 2 questions.
which of lines causing error?
table
should have been replaced table-name, shouldnt it? http://www.postgresql.org/docs/8.2/static/sql-insert.html
Comments
Post a Comment