Fixed issue with missing optional table alias in MERGE usage

This commit is contained in:
Arjen Duursma 2024-06-27 13:33:00 +02:00
parent cd41d70546
commit f994ae0e6f
3 changed files with 115 additions and 4 deletions

View File

@ -2690,7 +2690,7 @@ ASTDeleteStatement DeleteStatement() :
ASTMergeStatement MergeStatement() :
{}
{
<MERGE> <INTO> [ LOOKAHEAD(2) SchemaName() "." ] TableName() [ TableAlias() ]
<MERGE> <INTO> [ LOOKAHEAD(2) SchemaName() "." ] TableName() [ LOOKAHEAD(1, ID(), { getToken(1).kind != USING } ) TableAlias() ]
<USING>
(
LOOKAHEAD(3) "(" ValuesClause() ")"

View File

@ -13,5 +13,13 @@ BEGIN
THEN UPDATE SET b.text = e.text
WHEN NOT MATCHED
THEN INSERT (ID,KEY1, TEXT,LCE_ID) values (JHS_SEQ.NEXTVAL,'PROM_EDIT_PROM_NR','Edycja promocji nr',123123);
MERGE INTO b
USING ( SELECT 'PROM_EDIT_PROM_NR' key1,'Edycja promocji nr' text,123123 lce_id FROM dual ) e
ON (b.key1 = e.key1 and b.lce_id=e.lce_id)
WHEN MATCHED
THEN UPDATE SET b.text = e.text
WHEN NOT MATCHED
THEN INSERT (ID,KEY1, TEXT,LCE_ID) values (JHS_SEQ.NEXTVAL,'PROM_EDIT_PROM_NR','Edycja promocji nr',123123);
END;
/

View File

@ -1,12 +1,115 @@
+- Input[@CanonicalImage = null, @ExcludedLinesCount = 0, @ExcludedRangesCount = 0]
+- Global[@CanonicalImage = null]
+- Block[@CanonicalImage = null]
+- Statement[@CanonicalImage = null]
| +- UnlabelledStatement[@CanonicalImage = null]
| +- MergeStatement[@CanonicalImage = null]
| +- TableName[@CanonicalImage = "JHS_TRANSLATIONS", @Image = "jhs_translations"]
| | +- ID[@CanonicalImage = "JHS_TRANSLATIONS", @Image = "jhs_translations"]
| +- TableAlias[@CanonicalImage = "B", @Image = "b"]
| | +- ID[@CanonicalImage = "B", @Image = "b"]
| +- QueryBlock[@All = false, @CanonicalImage = null, @Distinct = false, @Unique = false]
| | +- SelectList[@CanonicalImage = null]
| | | +- SqlExpression[@CanonicalImage = "\'PROM_EDIT_PROM_NR\'", @Image = "\'PROM_EDIT_PROM_NR\'"]
| | | | +- PrimaryPrefix[@CanonicalImage = "\'PROM_EDIT_PROM_NR\'", @Image = "\'PROM_EDIT_PROM_NR\'", @SelfModifier = false]
| | | | +- Literal[@CanonicalImage = "\'PROM_EDIT_PROM_NR\'", @Image = "\'PROM_EDIT_PROM_NR\'"]
| | | | +- StringLiteral[@CanonicalImage = "\'PROM_EDIT_PROM_NR\'", @Image = "\'PROM_EDIT_PROM_NR\'", @String = "PROM_EDIT_PROM_NR"]
| | | +- ColumnAlias[@CanonicalImage = "KEY1", @Image = "key1"]
| | | | +- ID[@CanonicalImage = "KEY1", @Image = "key1"]
| | | +- SqlExpression[@CanonicalImage = "\'EDYCJA PROMOCJI NR\'", @Image = "\'Edycja promocji nr\'"]
| | | | +- PrimaryPrefix[@CanonicalImage = "\'EDYCJA PROMOCJI NR\'", @Image = "\'Edycja promocji nr\'", @SelfModifier = false]
| | | | +- Literal[@CanonicalImage = "\'EDYCJA PROMOCJI NR\'", @Image = "\'Edycja promocji nr\'"]
| | | | +- StringLiteral[@CanonicalImage = "\'EDYCJA PROMOCJI NR\'", @Image = "\'Edycja promocji nr\'", @String = "Edycja promocji nr"]
| | | +- ColumnAlias[@CanonicalImage = "TEXT", @Image = "text"]
| | | | +- ID[@CanonicalImage = "TEXT", @Image = "text"]
| | | +- SqlExpression[@CanonicalImage = "123123", @Image = "123123"]
| | | | +- PrimaryPrefix[@CanonicalImage = "123123", @Image = "123123", @SelfModifier = false]
| | | | +- Literal[@CanonicalImage = "123123", @Image = "123123"]
| | | | +- NumericLiteral[@CanonicalImage = "123123", @Image = "123123"]
| | | +- ColumnAlias[@CanonicalImage = "LCE_ID", @Image = "lce_id"]
| | | +- ID[@CanonicalImage = "LCE_ID", @Image = "lce_id"]
| | +- FromClause[@CanonicalImage = null]
| | +- TableReference[@CanonicalImage = null]
| | +- TableName[@CanonicalImage = "DUAL", @Image = "dual"]
| | +- ID[@CanonicalImage = "DUAL", @Image = "dual"]
| +- TableAlias[@CanonicalImage = "E", @Image = "e"]
| | +- ID[@CanonicalImage = "E", @Image = "e"]
| +- Condition[@CanonicalImage = null]
| | +- CompoundCondition[@CanonicalImage = null, @Type = "AND"]
| | +- ComparisonCondition[@CanonicalImage = null, @Operator = "="]
| | | +- SqlExpression[@CanonicalImage = "B.KEY1", @Image = "b.key1"]
| | | | +- PrimaryPrefix[@CanonicalImage = "B.KEY1", @Image = "b.key1", @SelfModifier = false]
| | | | +- SimpleExpression[@CanonicalImage = "B.KEY1", @Image = "b.key1"]
| | | | +- TableName[@CanonicalImage = "B", @Image = "b"]
| | | | | +- ID[@CanonicalImage = "B", @Image = "b"]
| | | | +- Column[@CanonicalImage = "KEY1", @Image = "key1"]
| | | | +- ID[@CanonicalImage = "KEY1", @Image = "key1"]
| | | +- SqlExpression[@CanonicalImage = "E.KEY1", @Image = "e.key1"]
| | | +- PrimaryPrefix[@CanonicalImage = "E.KEY1", @Image = "e.key1", @SelfModifier = false]
| | | +- SimpleExpression[@CanonicalImage = "E.KEY1", @Image = "e.key1"]
| | | +- TableName[@CanonicalImage = "E", @Image = "e"]
| | | | +- ID[@CanonicalImage = "E", @Image = "e"]
| | | +- Column[@CanonicalImage = "KEY1", @Image = "key1"]
| | | +- ID[@CanonicalImage = "KEY1", @Image = "key1"]
| | +- Condition[@CanonicalImage = null]
| | +- CompoundCondition[@CanonicalImage = null, @Type = null]
| | +- ComparisonCondition[@CanonicalImage = null, @Operator = "="]
| | +- SqlExpression[@CanonicalImage = "B.LCE_ID", @Image = "b.lce_id"]
| | | +- PrimaryPrefix[@CanonicalImage = "B.LCE_ID", @Image = "b.lce_id", @SelfModifier = false]
| | | +- SimpleExpression[@CanonicalImage = "B.LCE_ID", @Image = "b.lce_id"]
| | | +- TableName[@CanonicalImage = "B", @Image = "b"]
| | | | +- ID[@CanonicalImage = "B", @Image = "b"]
| | | +- Column[@CanonicalImage = "LCE_ID", @Image = "lce_id"]
| | | +- ID[@CanonicalImage = "LCE_ID", @Image = "lce_id"]
| | +- SqlExpression[@CanonicalImage = "E.LCE_ID", @Image = "e.lce_id"]
| | +- PrimaryPrefix[@CanonicalImage = "E.LCE_ID", @Image = "e.lce_id", @SelfModifier = false]
| | +- SimpleExpression[@CanonicalImage = "E.LCE_ID", @Image = "e.lce_id"]
| | +- TableName[@CanonicalImage = "E", @Image = "e"]
| | | +- ID[@CanonicalImage = "E", @Image = "e"]
| | +- Column[@CanonicalImage = "LCE_ID", @Image = "lce_id"]
| | +- ID[@CanonicalImage = "LCE_ID", @Image = "lce_id"]
| +- MergeUpdateClause[@CanonicalImage = null]
| | +- TableName[@CanonicalImage = "B", @Image = "b"]
| | | +- ID[@CanonicalImage = "B", @Image = "b"]
| | +- Column[@CanonicalImage = "TEXT", @Image = "text"]
| | | +- ID[@CanonicalImage = "TEXT", @Image = "text"]
| | +- Expression[@CanonicalImage = "E.TEXT", @Image = "e.text"]
| | +- PrimaryPrefix[@CanonicalImage = "E.TEXT", @Image = "e.text", @SelfModifier = false]
| | +- SimpleExpression[@CanonicalImage = "E.TEXT", @Image = "e.text"]
| | +- TableName[@CanonicalImage = "E", @Image = "e"]
| | | +- ID[@CanonicalImage = "E", @Image = "e"]
| | +- Column[@CanonicalImage = "TEXT", @Image = "text"]
| | +- ID[@CanonicalImage = "TEXT", @Image = "text"]
| +- MergeInsertClause[@CanonicalImage = null]
| +- Column[@CanonicalImage = "ID", @Image = "ID"]
| | +- ID[@CanonicalImage = "ID", @Image = "ID"]
| +- Column[@CanonicalImage = "KEY1", @Image = "KEY1"]
| | +- ID[@CanonicalImage = "KEY1", @Image = "KEY1"]
| +- Column[@CanonicalImage = "TEXT", @Image = "TEXT"]
| | +- ID[@CanonicalImage = "TEXT", @Image = "TEXT"]
| +- Column[@CanonicalImage = "LCE_ID", @Image = "LCE_ID"]
| | +- ID[@CanonicalImage = "LCE_ID", @Image = "LCE_ID"]
| +- ValuesClause[@CanonicalImage = null]
| +- Expression[@CanonicalImage = "", @Image = ""]
| | +- PrimaryPrefix[@CanonicalImage = "", @Image = "", @SelfModifier = false]
| | +- SimpleExpression[@CanonicalImage = "", @Image = ""]
| | +- ID[@CanonicalImage = "JHS_SEQ", @Image = "JHS_SEQ"]
| +- Expression[@CanonicalImage = "\'PROM_EDIT_PROM_NR\'", @Image = "\'PROM_EDIT_PROM_NR\'"]
| | +- PrimaryPrefix[@CanonicalImage = "\'PROM_EDIT_PROM_NR\'", @Image = "\'PROM_EDIT_PROM_NR\'", @SelfModifier = false]
| | +- Literal[@CanonicalImage = "\'PROM_EDIT_PROM_NR\'", @Image = "\'PROM_EDIT_PROM_NR\'"]
| | +- StringLiteral[@CanonicalImage = "\'PROM_EDIT_PROM_NR\'", @Image = "\'PROM_EDIT_PROM_NR\'", @String = "PROM_EDIT_PROM_NR"]
| +- Expression[@CanonicalImage = "\'EDYCJA PROMOCJI NR\'", @Image = "\'Edycja promocji nr\'"]
| | +- PrimaryPrefix[@CanonicalImage = "\'EDYCJA PROMOCJI NR\'", @Image = "\'Edycja promocji nr\'", @SelfModifier = false]
| | +- Literal[@CanonicalImage = "\'EDYCJA PROMOCJI NR\'", @Image = "\'Edycja promocji nr\'"]
| | +- StringLiteral[@CanonicalImage = "\'EDYCJA PROMOCJI NR\'", @Image = "\'Edycja promocji nr\'", @String = "Edycja promocji nr"]
| +- Expression[@CanonicalImage = "123123", @Image = "123123"]
| +- PrimaryPrefix[@CanonicalImage = "123123", @Image = "123123", @SelfModifier = false]
| +- Literal[@CanonicalImage = "123123", @Image = "123123"]
| +- NumericLiteral[@CanonicalImage = "123123", @Image = "123123"]
+- Statement[@CanonicalImage = null]
+- UnlabelledStatement[@CanonicalImage = null]
+- MergeStatement[@CanonicalImage = null]
+- TableName[@CanonicalImage = "JHS_TRANSLATIONS", @Image = "jhs_translations"]
| +- ID[@CanonicalImage = "JHS_TRANSLATIONS", @Image = "jhs_translations"]
+- TableAlias[@CanonicalImage = "B", @Image = "b"]
+- TableName[@CanonicalImage = "B", @Image = "b"]
| +- ID[@CanonicalImage = "B", @Image = "b"]
+- QueryBlock[@All = false, @CanonicalImage = null, @Distinct = false, @Unique = false]
| +- SelectList[@CanonicalImage = null]