DBI::BaseStatement
See DBI::BaseStatement, and DBI::DBD::Pg::Tuples.
# File lib/dbd/pg/statement.rb, line 13 def initialize(db, sql) super(db) @db = db @sql = sql @stmt_name = PG_STMT_NAME_PREFIX + self.object_id.to_s + Time.now.to_f.to_s @result = nil @bindvars = [] @prepared = false rescue PGError => err raise DBI::ProgrammingError.new(err.message) end
Attributes:
If pg_row_count is requested and the statement has already executed, postgres will return what it believes is the row count.
# File lib/dbd/pg/statement.rb, line 100 def [](attr) case attr when 'pg_row_count' if @result @result.row_count else nil end else @attr[attr] end end
# File lib/dbd/pg/statement.rb, line 25 def bind_param(index, value, options) @bindvars[index-1] = value end
See DBI::DBD::Pg::Tuples#column_info.
# File lib/dbd/pg/statement.rb, line 82 def column_info @result.column_info end
See DBI::BaseDatabase#execute.
This method will make use of PostgreSQL's native BLOB support if DBI::Binary objects are passed in.
# File lib/dbd/pg/statement.rb, line 35 def execute # replace DBI::Binary object by oid returned by lo_import @bindvars.collect! do |var| if var.is_a? DBI::Binary then oid = @db.__blob_create(PGconn::INV_WRITE) @db.__blob_write(oid, var.to_s) oid else var end end internal_prepare if not @db['AutoCommit'] then # if not SQL.query?(boundsql) and not @db['AutoCommit'] then @db.start_transaction unless @db.in_transaction? end if @db["pg_native_binding"] pg_result = @db._exec_prepared(@stmt_name, *@bindvars) else pg_result = @db._exec_prepared(@stmt_name) end @result = DBI::DBD::Pg::Tuples.new(@db, pg_result) rescue PGError, RuntimeError => err raise DBI::ProgrammingError.new(err.message) end
# File lib/dbd/pg/statement.rb, line 65 def fetch @result.fetchrow end
# File lib/dbd/pg/statement.rb, line 69 def fetch_scroll(direction, offset) @result.fetch_scroll(direction, offset) end
Generated with the Darkfish Rdoc Generator 2.