You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "zihaoAK47 (via GitHub)" <gi...@apache.org> on 2023/12/31 08:23:25 UTC

Re: [PR] [Parser Oracle] Support Create Trigger Statement [shardingsphere]

zihaoAK47 commented on code in PR #29604:
URL: https://github.com/apache/shardingsphere/pull/29604#discussion_r1438844676


##########
parser/sql/dialect/oracle/src/main/antlr4/imports/oracle/DMLStatement.g4:
##########
@@ -77,6 +77,14 @@ dmlSubqueryClause
     : LP_ selectSubquery subqueryRestrictionClause? RP_
     ;
 
+dmlEventClause
+    : dmlEventElement (OR dmlEventElement)* ON viewName

Review Comment:
   Suggest the same as above.



##########
parser/sql/dialect/oracle/src/main/antlr4/imports/oracle/DDLStatement.g4:
##########
@@ -43,6 +43,10 @@ createType
     : CREATE (OR REPLACE)? (EDITIONABLE | NONEDITIONABLE)? TYPE plsqlTypeSource
     ;
 
+createTrigger
+    : CREATE (OR REPLACE)? TRIGGER triggerName (BEFORE | AFTER | INSTEAD OF) dmlEventClause

Review Comment:
   Hi can we put the definition of this syntax in the PLSQL.g4 file?
   ![2023-12-31_16-07](https://github.com/apache/shardingsphere/assets/106047330/cf259483-e8f6-47f9-b82c-2e2122c2450a)
   
   Syntax ref: https://docs.oracle.com/en/database/oracle/oracle-database/19/lnpls/CREATE-TRIGGER-statement.html#GUID-AF9E33F1-64D1-4382-A6A4-EC33C36F237B



##########
parser/sql/dialect/oracle/src/main/antlr4/imports/oracle/DMLStatement.g4:
##########
@@ -77,6 +77,14 @@ dmlSubqueryClause
     : LP_ selectSubquery subqueryRestrictionClause? RP_
     ;
 
+dmlEventClause
+    : dmlEventElement (OR dmlEventElement)* ON viewName
+    ;
+
+dmlEventElement
+    : (DELETE | INSERT | UPDATE) (OF LP_ columnName (COMMA_ columnName)* RP_)?

Review Comment:
   Suggest the same as above.



##########
parser/sql/statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/oracle/ddl/OracleCreateTriggerStatement.java:
##########
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.sql.parser.sql.dialect.statement.oracle.ddl;
+
+import org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.CreateTablespaceStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.oracle.OracleStatement;
+
+/**
+ * Oracle create trigger statement.
+ */
+public final class OracleCreateTriggerStatement extends CreateTablespaceStatement implements OracleStatement {

Review Comment:
   Why do we need to extend the `CreatTablespaceStatement` here?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org