PostgreSQL
 sql >> Teknologi Basis Data >  >> RDS >> PostgreSQL

Pernyataan yang Disiapkan Sudah Ada

Coba jalankan:

conn.exec("DEALLOCATE name_of_prepared_statement")

Dalam contoh Anda:

conn.exec("DEALLOCATE insert_values")

Tes sederhana dan berhasil di irb saya:

1.8.7 :001 > require 'rubygems'
  => true
1.8.7 :002 > require 'pg'
  => true
1.8.7 :003 > conn = PGconn.connect(:host => 'localhost', :port => 5912, :user => 'test', :dbname => 'test' )
  => #<PGconn:0x7fe6ac703970> 
1.8.7 :005 > conn.prepare("insert_values", "select * from data where id < $1")
  => #<PGresult:0x7fe6ac6b2e58> 
1.8.7 :006 > conn.prepare("insert_values", "select * from data where id < $1 and id >   $2")
  PGError: ERROR:  prepared statement "insert_values" already exists

  from (irb):6:in 'prepare'
  from (irb):6
1.8.7 :007 > conn.prepare("insert_values", "select * from data where id < $1")
  PGError: ERROR:  prepared statement "insert_values" already exists

  from (irb):7:in 'prepare'
  from (irb):7
1.8.7 :008 > conn.exec("DEALLOCATE insert_values")
  => #<PGresult:0x7fe6ac6738c0> 
1.8.7 :009 > conn.prepare("insert_values", "select * from data where id < $1")
  => #<PGresult:0x7fe6ac665fe0> 
1.8.7 :010 > conn.exec_prepared("insert_values",[200])
  => #<PGresult:0x7fe6ac65d188> 
1.8.7 :011 > conn.exec("DEALLOCATE insert_values")
  => #<PGresult:0x7fe6ac654df8> 
1.8.7 :012 > conn.exec_prepared("insert_values",[200])
  PGError: ERROR:  prepared statement "insert_values" does not exist

  from (irb):12:in 'exec_prepared'
  from (irb):12


  1. Database
  2.   
  3. Mysql
  4.   
  5. Oracle
  6.   
  7. Sqlserver
  8.   
  9. PostgreSQL
  10.   
  11. Access
  12.   
  13. SQLite
  14.   
  15. MariaDB
  1. Bermigrasi secara bertahap dari SQL Server ke PostgreSQL

  2. org.postgresql.util.PSQLException:ERROR:kolom user0_.id tidak ada - Hibernate

  3. PostgreSQL setara dengan pengumpulan massal Oracle

  4. Menggunakan Slot Replikasi PostgreSQL

  5. Django 1.8 Migrasi dengan Postgres BDR 9.4.1