forked from JSQLParser/JSqlParser
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- supports Oracle's `RETURN ... INTO ...` - fixes JSQLParser#1780 - fixes JSQLParser#686 - Special Oracle tests `insert11.sql` and `insert12.sql`
- Loading branch information
1 parent
daa56ed
commit 4fb1cfb
Showing
23 changed files
with
277 additions
and
132 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
src/main/java/net/sf/jsqlparser/expression/RangeExpression.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
src/main/java/net/sf/jsqlparser/expression/operators/relational/MemberOfExpression.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 97 additions & 0 deletions
97
src/main/java/net/sf/jsqlparser/statement/ReturningClause.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/*- | ||
* #%L | ||
* JSQLParser library | ||
* %% | ||
* Copyright (C) 2004 - 2023 JSQLParser | ||
* %% | ||
* Dual licensed under GNU LGPL 2.1 or Apache License 2.0 | ||
* #L% | ||
*/ | ||
package net.sf.jsqlparser.statement; | ||
|
||
import net.sf.jsqlparser.statement.select.SelectItem; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* RETURNING clause according to | ||
* {@see https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/DELETE.html#GUID-156845A5-B626-412B-9F95-8869B988ABD7 | ||
* } Part of UPDATE, INSERT, DELETE statements | ||
*/ | ||
|
||
public class ReturningClause extends ArrayList<SelectItem<?>> { | ||
enum Keyword { | ||
RETURN, RETURNING; | ||
|
||
public static Keyword from(String keyword) { | ||
return Enum.valueOf(Keyword.class, keyword.toUpperCase()); | ||
} | ||
} | ||
|
||
private Keyword keyword; | ||
|
||
/** | ||
* List of output targets like Table or UserVariable | ||
*/ | ||
private final List<Object> dataItems; | ||
|
||
public ReturningClause(Keyword keyword, List<SelectItem<?>> selectItems, | ||
List<Object> dataItems) { | ||
this.keyword = keyword; | ||
this.addAll(selectItems); | ||
this.dataItems = dataItems; | ||
} | ||
|
||
public ReturningClause(String keyword, List<SelectItem<?>> selectItems, | ||
List<Object> dataItems) { | ||
this(Keyword.from(keyword), selectItems, dataItems); | ||
} | ||
|
||
public ReturningClause(Keyword keyword, List<SelectItem<?>> selectItems) { | ||
this(keyword, selectItems, null); | ||
} | ||
|
||
public ReturningClause(String keyword, List<SelectItem<?>> selectItems) { | ||
this(Keyword.valueOf(keyword), selectItems, null); | ||
} | ||
|
||
public Keyword getKeyword() { | ||
return keyword; | ||
} | ||
|
||
public ReturningClause setKeyword(Keyword keyword) { | ||
this.keyword = keyword; | ||
return this; | ||
} | ||
|
||
public List<?> getDataItems() { | ||
return dataItems; | ||
} | ||
|
||
public StringBuilder appendTo(StringBuilder builder) { | ||
builder.append(" ").append(keyword).append(" "); | ||
for (int i = 0; i < size(); i++) { | ||
if (i > 0) { | ||
builder.append(", "); | ||
} | ||
builder.append(get(i)); | ||
} | ||
|
||
if (dataItems != null && dataItems.size() > 0) { | ||
builder.append(" INTO "); | ||
for (int i = 0; i < dataItems.size(); i++) { | ||
if (i > 0) { | ||
builder.append(" ,"); | ||
} | ||
builder.append(dataItems.get(i)); | ||
} | ||
} | ||
return builder; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return appendTo(new StringBuilder()).toString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.