Skip to content

Commit 17e3d53

Browse files
committed
Update JSqlParserCC.jj
Add support for DB2 Updates with Select clause
1 parent 232795f commit 17e3d53

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

src/main/javacc/net/sf/jsqlparser/parser/JSqlParserCC.jj

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,12 +311,27 @@ Update Update():
311311
Expression value = null;
312312
FromItem fromItem = null;
313313
List<Join> joins = null;
314+
Select select = null;
315+
boolean useColumnsBrackets = false;
314316
}
315317
{
316318
<K_UPDATE> table=TableWithAlias() { tables.add(table); }
317319
("," table=TableWithAlias() { tables.add(table); } )*
318-
<K_SET> tableColumn=Column() "=" value=SimpleExpression() { columns.add(tableColumn); expList.add(value); }
319-
("," tableColumn=Column() "=" value=SimpleExpression() { columns.add(tableColumn); expList.add(value); } )*
320+
<K_SET>
321+
(
322+
tableColumn=Column() "=" value=SimpleExpression() { columns.add(tableColumn); expList.add(value); }
323+
("," tableColumn=Column() "=" value=SimpleExpression() { columns.add(tableColumn); expList.add(value); } )*
324+
325+
|
326+
327+
[LOOKAHEAD(2) "(" { useColumnsBrackets = true; }] tableColumn=Column() { columns.add(tableColumn); } ("," tableColumn=Column() { columns.add(tableColumn); } )* [ ")" ] "="
328+
"("
329+
(
330+
{ update.setUseSelect(true); }
331+
select = Select()
332+
)
333+
")"
334+
)
320335

321336
[ <K_FROM>
322337
fromItem=FromItem()
@@ -329,6 +344,8 @@ Update Update():
329344
update.setTables(tables);
330345
update.setFromItem(fromItem);
331346
update.setJoins(joins);
347+
update.setSelect(select);
348+
update.setUseColumnsBrackets(useColumnsBrackets);
332349
return update;
333350
}
334351
}
@@ -2369,4 +2386,4 @@ Alter Alter():
23692386
alter.setDataType(dataType);
23702387
return alter;
23712388
}
2372-
}
2389+
}

0 commit comments

Comments
 (0)