我看过链接
How to fix PG::DuplicatePstatement: ERROR?
但它仍然无法解决我收到的错误消息
`prepare': ERROR: prepared statement "should_insert" already exists (PG::DuplicatePstatement)
我在哪里放置上述链接中的答案代码块?我是否必须调用方法才能执行它?
db_connection = PGconn.connect("localhost", 5433, '', '', "dev_ddb", "user", "pass")
db_connection.prepare('should_insert', 'SELECT COUNT(*) from users where user_id = $1')
答案 0 :(得分:1)
我能够通过释放准备好的声明来解决这个问题。我在exec_prepared语句之后插入了这一行。
db_connection.exec("DEALLOCATE should_insert")