コード例 #1
0
        public static SqlStatement Build(PlSqlParser.DeleteStatementContext context)
        {
            var tableName   = Name.Object(context.objectName());
            var whereClause = WhereClause.Form(context.whereClause());

            if (whereClause.CurrentOf != null)
            {
                return(new DeleteCurrentStatement(tableName, whereClause.CurrentOf));
            }

            var statement = new DeleteStatement(tableName, whereClause.Expression);

            if (context.deleteLimit() != null)
            {
                var limit = Number.PositiveInteger(context.deleteLimit().numeric());
                if (limit == null)
                {
                    throw new ParseCanceledException("Invalid delete limit.");
                }

                statement.Limit = limit.Value;
            }

            return(statement);
        }