Package com.exasol.sql.dml.merge
Class Merge
- java.lang.Object
-
- com.exasol.sql.AbstractFragment
-
- com.exasol.sql.dml.merge.Merge
-
- All Implemented Interfaces:
MergeFragment
,Fragment
,SqlStatement
public class Merge extends AbstractFragment implements SqlStatement, MergeFragment
-
-
Field Summary
-
Fields inherited from class com.exasol.sql.AbstractFragment
root
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
accept(MergeVisitor visitor)
Accept a visitor (e.g.MatchedClause
getMatched()
Get theWHEN MATCHED
clause.MatchedClause
getNotMatched()
Get theWHEN NOT MATCHED
clause.OnClause
getOn()
Get the merge criteria (i.e.UsingClause
getUsing()
Get theUSING
clause of theMERGE
statement.protected boolean
hasMatched()
Check if theWHEN MATCHED
clause exists.protected boolean
hasNotMatched()
Check if theWHEN NOT MATCHED
clause exists.protected boolean
hasOn()
Check if theON
clause exists.protected boolean
hasUsing()
Check if theUSING
clause exists.Merge
on(BooleanExpression condition)
Define the merge criteria.Merge
using(String sourceTable)
Define the data source.Merge
using(String sourceTable, String as)
Define the data source.MatchedClause
whenMatched()
Define the merge strategy if the match criteria is met.NotMatchedClause
whenNotMatched()
Define the merge strategy if the match criteria is not met.-
Methods inherited from class com.exasol.sql.AbstractFragment
getRoot
-
-
-
-
Method Detail
-
using
public Merge using(String sourceTable)
Define the data source.- Parameters:
sourceTable
- table where the data to be merged originates- Returns:
this
for fluent programming
-
using
public Merge using(String sourceTable, String as)
Define the data source.- Parameters:
sourceTable
- table where the data to be merged originatesas
- table alias- Returns:
this
for fluent programming
-
getUsing
public UsingClause getUsing()
Get theUSING
clause of theMERGE
statement.- Returns:
- destination table
-
hasUsing
protected boolean hasUsing()
Check if theUSING
clause exists.- Returns:
true
if theUSING
clause exists.
-
on
public Merge on(BooleanExpression condition)
Define the merge criteria.- Parameters:
condition
- criteria that must be met for the rows in source and destination to be considered a match.- Returns:
this
for fluent programming
-
getOn
public OnClause getOn()
Get the merge criteria (i.e. the `ON` clause).- Returns:
- criteria that must be met for the rows in source and destination to be considered a match.
-
hasOn
protected boolean hasOn()
Check if theON
clause exists.- Returns:
true
if theON
clause exists.
-
whenMatched
public MatchedClause whenMatched()
Define the merge strategy if the match criteria is met.- Returns:
- match strategy
-
hasMatched
protected boolean hasMatched()
Check if theWHEN MATCHED
clause exists.- Returns:
true
if theWHEN MATCHED
clause exists
-
getMatched
public MatchedClause getMatched()
Get theWHEN MATCHED
clause.- Returns:
WHEN MATCHED
clause
-
whenNotMatched
public NotMatchedClause whenNotMatched()
Define the merge strategy if the match criteria is not met.- Returns:
- not matched strategy
-
hasNotMatched
protected boolean hasNotMatched()
Check if theWHEN NOT MATCHED
clause exists.- Returns:
- true if the
WHEN NOT MATCHED
clause exists
-
getNotMatched
public MatchedClause getNotMatched()
Get theWHEN NOT MATCHED
clause.- Returns:
WHEN NOT MATCHED
clause
-
accept
public void accept(MergeVisitor visitor)
Description copied from interface:MergeFragment
Accept a visitor (e.g. a renderer or validator).- Specified by:
accept
in interfaceMergeFragment
- Parameters:
visitor
- visitor to accept
-
-