|
17 | 17 |
|
18 | 18 | grammar StoreProcedure;
|
19 | 19 |
|
20 |
| -import Keyword; |
| 20 | +import Keyword, BaseRule, DDLStatement, DMLStatement; |
21 | 21 |
|
22 | 22 | call
|
23 | 23 | : CALL
|
24 | 24 | ;
|
| 25 | + |
| 26 | +createProcedure |
| 27 | + : CREATE (OR REPLACE)? (EDITIONABLE | NONEDITIONABLE)? PROCEDURE plsqlProcedureSource |
| 28 | + ; |
| 29 | + |
| 30 | +plsqlProcedureSource |
| 31 | + : (schemaName DOT_)? procedureName ( LP_ parameterDeclaration ( COMMA_ parameterDeclaration )* RP_)? sharingClause? |
| 32 | + ((defaultCollationClause | invokerRightsClause | accessibleByClause)*)? (IS | AS) (callSpec | declareSection? body) |
| 33 | + ; |
| 34 | + |
| 35 | +body |
| 36 | + : BEGIN statement+ (EXCEPTION (exceptionHandler)+)? END (identifier)? SEMI_ |
| 37 | + ; |
| 38 | + |
| 39 | +//need add more statement type according to the doc |
| 40 | +statement |
| 41 | + : ( SIGNED_LEFT_SHIFT_ label SIGNED_RIGHT_SHIFT_ ( SIGNED_LEFT_SHIFT_ label SIGNED_RIGHT_SHIFT_ ) *)? |
| 42 | + ( select |
| 43 | + | update |
| 44 | + | delete |
| 45 | + | insert |
| 46 | + | lockTable |
| 47 | + | merge |
| 48 | + ) SEMI_ |
| 49 | + ; |
| 50 | + |
| 51 | +exceptionHandler |
| 52 | + : WHEN ( (typeName (OR typeName)* )| OTHERS ) THEN statement+ |
| 53 | + ; |
| 54 | + |
| 55 | +declareSection |
| 56 | + : itemList1 itemList2? |
| 57 | + | itemList2 |
| 58 | + ; |
| 59 | + |
| 60 | +itemList2 |
| 61 | + : cursorDeclaration | cursorDefinition | functionDeclaration | functionDefinition | procedureDeclaration | procedureDefinition |
| 62 | + ; |
| 63 | + |
| 64 | +cursorDefinition |
| 65 | + : CURSOR variableName ( LP_ cursorParameterDec ( COMMA_ cursorParameterDec )* RP_)? ( RETURN rowtype)? IS select SEMI_ |
| 66 | + ; |
| 67 | + |
| 68 | +functionDefinition |
| 69 | + : functionHeading ( DETERMINISTIC | PIPELINED | PARALLEL_ENABLE | resultCacheClause )+ ( IS | AS ) ( declareSection ? body | callSpec ) |
| 70 | + ; |
| 71 | + |
| 72 | +procedureDefinition |
| 73 | + : procedureDeclaration (IS | AS) (callSpec | declareSection? body) |
| 74 | + ; |
| 75 | + |
| 76 | +itemList1 |
| 77 | + :( typeDefinition | cursorDeclaration | itemDeclaration | functionDeclaration | procedureDeclaration )* |
| 78 | + ; |
| 79 | + |
| 80 | +cursorDeclaration |
| 81 | + : CURSOR variableName ( ( cursorParameterDec (COMMA_ cursorParameterDec )* ) )? RETURN rowtype SEMI_ |
| 82 | + ; |
| 83 | + |
| 84 | +cursorParameterDec |
| 85 | + : variableName IN? dataType ( (COLON_ EQ_ | DEFAULT) expr )? |
| 86 | + ; |
| 87 | + |
| 88 | +rowtype |
| 89 | + : typeName MOD_ ROWTYPE |
| 90 | + | typeName (MOD_ TYPE)? |
| 91 | + ; |
| 92 | + |
| 93 | +itemDeclaration |
| 94 | + : collectionVariableDecl | constantDeclaration | cursorVariableDeclaration | exceptionDeclaration | recordVariableDeclaration | variableDeclaration |
| 95 | + ; |
| 96 | + |
| 97 | +collectionVariableDecl |
| 98 | + : variableName |
| 99 | + ( |
| 100 | + typeName ( COLON_ EQ_ ( qualifiedExpression | functionCall | variableName ) )? |
| 101 | + | typeName ( COLON_ EQ_ ( collectionConstructor | variableName ) )? |
| 102 | + | typeName MOD_ TYPE |
| 103 | + ) |
| 104 | + SEMI_ |
| 105 | + ; |
| 106 | + |
| 107 | +qualifiedExpression |
| 108 | + : typemark LP_ aggregate RP_ |
| 109 | + ; |
| 110 | + |
| 111 | +aggregate |
| 112 | + : positionalChoiceList? explicitChoiceList? |
| 113 | + ; |
| 114 | + |
| 115 | +explicitChoiceList |
| 116 | + : namedChoiceList | indexedChoiceList |
| 117 | + ; |
| 118 | + |
| 119 | +namedChoiceList |
| 120 | + : identifier EQ_ GT_ expr (COMMA_ identifier EQ_ GT_ expr)* |
| 121 | + ; |
| 122 | + |
| 123 | +indexedChoiceList |
| 124 | + : expr EQ_ GT_ expr (COMMA_ expr EQ_ GT_ expr)* |
| 125 | + ; |
| 126 | + |
| 127 | +positionalChoiceList |
| 128 | + : expr (COMMA_ expr)* |
| 129 | + ; |
| 130 | + |
| 131 | +typemark |
| 132 | + : typeName |
| 133 | + ; |
| 134 | + |
| 135 | +collectionConstructor |
| 136 | + : typeName LP_ ( identifier (COMMA_ identifier)* )? RP_ |
| 137 | + ; |
| 138 | + |
| 139 | +constantDeclaration |
| 140 | + : variableName CONSTANT dataType ( NOT NULL )? ( COLON_ EQ_ | DEFAULT ) expr SEMI_ |
| 141 | + ; |
| 142 | + |
| 143 | +cursorVariableDeclaration |
| 144 | + : variableName typeName SEMI_ |
| 145 | + ; |
| 146 | + |
| 147 | +exceptionDeclaration |
| 148 | + : variableName EXCEPTION SEMI_ |
| 149 | + ; |
| 150 | + |
| 151 | +recordVariableDeclaration |
| 152 | + : variableName ( typeName | rowtypeAttribute | typeName MOD_ TYPE ) SEMI_ |
| 153 | + ; |
| 154 | + |
| 155 | +variableDeclaration |
| 156 | + : variableName dataType ( ( NOT NULL )? ( COLON_ EQ_ | DEFAULT ) expr )? SEMI_ |
| 157 | + ; |
| 158 | + |
| 159 | +typeDefinition |
| 160 | + : collectionTypeDefinition | recordTypeDefinition | refCursorTypeDefinition | subtypeDefinition |
| 161 | + ; |
| 162 | + |
| 163 | +recordTypeDefinition |
| 164 | + : TYPE typeName IS RECORD LP_ fieldDefinition ( COMMA_ fieldDefinition )* RP_ SEMI_ |
| 165 | + ; |
| 166 | + |
| 167 | +fieldDefinition |
| 168 | + : typeName dataType ( ( NOT NULL )? ( COLON_ EQ_ | DEFAULT ) expr )? |
| 169 | + ; |
| 170 | + |
| 171 | +refCursorTypeDefinition |
| 172 | + : TYPE typeName IS REF CURSOR ( RETURN ( |
| 173 | + (typeName MOD_ ROWTYPE) |
| 174 | + | (typeName (MOD_ TYPE)?) |
| 175 | + ) )? SEMI_ |
| 176 | + ; |
| 177 | + |
| 178 | +subtypeDefinition |
| 179 | + : SUBTYPE typeName IS dataType ( constraint | characterSetClause )? ( NOT NULL )? |
| 180 | + ; |
| 181 | + |
| 182 | +constraint |
| 183 | + : (INTEGER_ COMMA_ INTEGER_) | (RANGE NUMBER_ DOT_ DOT_ NUMBER_) |
| 184 | + ; |
| 185 | + |
| 186 | +collectionTypeDefinition |
| 187 | + : TYPE typeName IS ( assocArrayTypeDef | varrayTypeDef | nestedTableTypeDef ) SEMI_ |
| 188 | + ; |
| 189 | + |
| 190 | +varrayTypeDef |
| 191 | + : ( VARRAY | (VARYING? ARRAY) ) LP_ INTEGER_ RP_ OF dataType ( NOT NULL )? |
| 192 | + ; |
| 193 | + |
| 194 | +nestedTableTypeDef |
| 195 | + : TABLE OF dataType ( NOT NULL )? |
| 196 | + ; |
| 197 | + |
| 198 | +assocArrayTypeDef |
| 199 | + : TABLE OF dataType ( NOT NULL )? INDEX BY ( PLS_INTEGER | BINARY_INTEGER | ( VARCHAR2 | VARCHAR2 | STRING ) LP_ INTEGER_ RP_ | LONG | typeAttribute | rowtypeAttribute ) |
| 200 | + ; |
| 201 | + |
| 202 | +typeAttribute |
| 203 | + : ( variableName | objectName ) MOD_ TYPE |
| 204 | + ; |
| 205 | + |
| 206 | +rowtypeAttribute |
| 207 | + : ( variableName | objectName ) MOD_ ROWTYPE |
| 208 | + ; |
0 commit comments