Method: JDBCHelper::TableWrapper#replace

Defined in:
lib/jdbc-helper/wrapper/table_wrapper.rb

#replace(data_hash = {}) ⇒ Fixnum

Note:

This is not SQL standard. Only works if the database supports replace syntax.

Replaces a record in the table with the new one with the same unique key.

Parameters:

  • data_hash (Hash) (defaults to: {})

    Column values in Hash

Returns:

  • (Fixnum)

    Number of affected records



94
95
96
97
98
99
100
# File 'lib/jdbc-helper/wrapper/table_wrapper.rb', line 94

def replace data_hash = {}
  sql, *binds = SQLHelper.replace :table => name,
                                  :data => @query_default.merge(data_hash),
                                  :prepared => true
  pstmt = prepare :insert, sql
  pstmt.send @update_method, *binds
end