Class: SQLStatement::SelectInsert

Inherits:
Select show all
Defined in:
lib/sql/statement.rb

Overview

Creates a statement of the form

INSERT INTO targettable (fields) SELECT values FROM ... WHERE ...

(The generated sql statement may contain aliases in the SELECT clause. This should be harmless.)

Instance Attribute Summary collapse

Attributes inherited from Select

#conditions, #distinct, #fields, #groupby, #orderby, #tables

Instance Method Summary collapse

Methods inherited from Select

#<<, #add_fields, #add_tables, #allfields, newlists, #placeheld, #to_sqlpart

Constructor Details

#initialize(targettable) ⇒ SelectInsert

Returns a new instance of SelectInsert.



456
457
458
459
# File 'lib/sql/statement.rb', line 456

def initialize(targettable)
   super()
   @targettable=targettable
end

Instance Attribute Details

#targettableObject

The name of the table to insert into.



454
455
456
# File 'lib/sql/statement.rb', line 454

def targettable
  @targettable
end

Instance Method Details

#to_sObject



461
462
463
# File 'lib/sql/statement.rb', line 461

def to_s
   "INSERT INTO #{@targettable.to_sqlpart} #{names_s} #{super}" 
end