SQL::Maker::SelectSet - provides set functions
use SQL::Maker::SelectSet qw(union_all except);
my $s1 = SQL::Maker::Select ->new()
->add_select('foo')
->add_from('t1');
my $s2 = SQL::Maker::Select ->new()
->add_select('bar')
->add_from('t2');
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.
- "union($select :SQL::Maker::Select | $set :SQL::Maker::SelectSet) :
SQL::Maker::SelectSet"
- Tow statements are combined by
"UNION".
- "union_all($select :SQL::Maker::Select | $set :SQL::Maker::SelectSet)
: SQL::Maker::SelectSet"
- Tow statements are combined by "UNION
ALL".
- "intersect($select :SQL::Maker::Select | $set :SQL::Maker::SelectSet)
: SQL::Maker::SelectSet"
- Tow statements are combined by
"INTERSECT".
- "intersect_all($select :SQL::Maker::Select | $set
:SQL::Maker::SelectSet) : SQL::Maker::SelectSet"
- Tow statements are combined by "INTERSECT
ALL".
- "except($select :SQL::Maker::Select | $set :SQL::Maker::SelectSet) :
SQL::Maker::SelectSet"
- Tow statements are combined by
"EXCEPT".
- "except($select :SQL::Maker::Select | $set :SQL::Maker::SelectSet) :
SQL::Maker::SelectSet"
- Tow statements are combined by "EXCEPT
ALL".
- my $stmt = SQL::Maker::SelectSet->new( %args )
- $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:
- $new_line
- Default values is "\n".
- $operator : Str
- The operator. This parameter is required.
- "my $sql = $set->as_sql() : Str"
- Returns a new select statement.
- "my @binds = $set->bind() : Array[Str]"
- Returns bind variables.
- "$set->add_statement($stmt : $stmt->can('as_sql')) :
SQL::Maker::SelectSet"
- This method adds new statement object. $stmt must
provides 'as_sql' method.
Return Value is the $set
itself.