SQL::Maker::SelectSet - provides set functions
include SQL::Maker::Helper
s1 = SQL::Maker::Select.new()
.add_select('foo')
.add_from('t1')
s2 = SQL::Maker::Select.new()
.add_select('bar')
.add_from('t2')
sql_union_all( s1, s2 ).as_sql
# =>
# SQL::Maker::SelectSet.new_set(
# :operator => 'UNION ALL',
# :new_line => s1.new_line
# ).add_statement(s1)
# .add_statement(s2)
# .as_sql
# => "SELECT foo FROM t1 UNION ALL SELECT bar FROM t2"
except( s1, s2 ).as_sql
# => SQL::Maker::SelectSet.new_set( :operator => 'EXCEPT', :new_line => s1.new_line )
# .add_statement( s1 )
# .add_statement( s2 )
# .as_sql
# => "SELECT foo FROM t1 EXCEPT SELECT bar FROM t2"
This module provides some set functions which return a SQL::Maker::SelectSet object inherited from SQL::Maker::Select.
Following functions will be avaiable with include SQL::Maker::Helper
.
Tow statements are combined by UNION.
Tow statements are combined by UNION ALL.
Tow statements are combined by INTERSECT.
Tow statements are combined by INTERSECT ALL.
Tow statements are combined by EXCEPT.
Tow statements are combined by EXCEPT ALL.
opretaor is a set operator (ex. UNION). one and another are SQL::Maker::Select object or SQL::Maker::SelectSet object. It returns a SQL::Maker::SelectSet object.
The parameters are:
Default values is "\n".
The operator. This parameter is required.
Returns a new select statement.
Returns bind variables.
This method adds new statement object. stmt must provides 'as_sql' method.
I is the set itself.