|
84 | 84 | import net.sf.jsqlparser.statement.create.usermapping.CreateUserMapping; |
85 | 85 | import net.sf.jsqlparser.statement.create.view.AlterView; |
86 | 86 | import net.sf.jsqlparser.statement.create.view.CreateView; |
| 87 | +import net.sf.jsqlparser.statement.cursor.CloseCursorStatement; |
| 88 | +import net.sf.jsqlparser.statement.cursor.DeclareCursorStatement; |
| 89 | +import net.sf.jsqlparser.statement.cursor.FetchCursorStatement; |
87 | 90 | import net.sf.jsqlparser.statement.delete.Delete; |
88 | 91 | import net.sf.jsqlparser.statement.drop.Drop; |
89 | 92 | import net.sf.jsqlparser.statement.drop.DropPolicy; |
@@ -991,6 +994,33 @@ public <S> Void visit(DeclareStatement declareStatement, S context) { |
991 | 994 | return sessionOnly(); |
992 | 995 | } |
993 | 996 |
|
| 997 | + @Override |
| 998 | + public <S> Void visit(DeclareCursorStatement declareCursor, S context) { |
| 999 | + // opens a cursor of the session over its query, which reads as the cursor is fetched |
| 1000 | + analysis.claimTopLevel(); |
| 1001 | + analysis.certain(StmtFeature.MODIFIES_SESSION); |
| 1002 | + if (declareCursor.getQuery() != null) { |
| 1003 | + declareCursor.getQuery().accept(analysis.selects, context); |
| 1004 | + } |
| 1005 | + return null; |
| 1006 | + } |
| 1007 | + |
| 1008 | + @Override |
| 1009 | + public <S> Void visit(FetchCursorStatement fetchCursor, S context) { |
| 1010 | + // moves the cursor and runs its query that far; only FETCH returns the rows |
| 1011 | + if (analysis.claimTopLevel() && fetchCursor.getKind() == FetchCursorStatement.Kind.FETCH) { |
| 1012 | + analysis.certain(StmtFeature.RETURNS_RESULT_SET); |
| 1013 | + } |
| 1014 | + analysis.certain(StmtFeature.MODIFIES_SESSION); |
| 1015 | + analysis.possible(StmtFeature.READS_DATA); |
| 1016 | + return null; |
| 1017 | + } |
| 1018 | + |
| 1019 | + @Override |
| 1020 | + public <S> Void visit(CloseCursorStatement closeCursor, S context) { |
| 1021 | + return sessionOnly(); |
| 1022 | + } |
| 1023 | + |
994 | 1024 | @Override |
995 | 1025 | public <S> Void visit(AlterSystemStatement alterSystemStatement, S context) { |
996 | 1026 | analysis.claimTopLevel(); |
|
0 commit comments