Inheritance: SqlStatement, IPreparableStatement
Esempio n. 1
0
        protected override SqlStatement VisitCreateSequence(CreateSequenceStatement statement)
        {
            builder.AppendFormat("CREATE SEQUENCE {0}", statement.SequenceName);

            if (statement.StartWith != null)
            {
                builder.AppendFormat(" START WITH {0}", statement.StartWith);
            }
            if (statement.MinValue != null)
            {
                builder.AppendFormat(" MIN VALUE {0}", statement.MinValue);
            }
            if (statement.MaxValue != null)
            {
                builder.AppendFormat(" MAX VALUE {0}", statement.MaxValue);
            }
            if (statement.IncrementBy != null)
            {
                builder.AppendFormat(" INCREMENT BY {0}", statement.IncrementBy);
            }
            if (statement.Cache != null)
            {
                builder.AppendFormat(" CACHE {0}", statement.Cache);
            }
            if (statement.Cycle)
            {
                builder.Append(" CYCLE");
            }

            return(base.VisitCreateSequence(statement));
        }
Esempio n. 2
0
        public void CreateWithDefaultValues()
        {
            var seqName   = ObjectName.Parse("APP.test_seq1");
            var statement = new CreateSequenceStatement(seqName);

            statement.Execute(Query);

            var exists = Query.ObjectExists(DbObjectType.Sequence, seqName);

            Assert.IsTrue(exists);
        }
        public void CreateWithDefaultValues()
        {
            var seqName = ObjectName.Parse("APP.test_seq1");
            var statement = new CreateSequenceStatement(seqName);

            statement.Execute(Query);

            var exists = Query.ObjectExists(DbObjectType.Sequence, seqName);

            Assert.IsTrue(exists);
        }
Esempio n. 4
0
 protected virtual SqlStatement VisitCreateSequence(CreateSequenceStatement statement)
 {
     return(new CreateSequenceStatement(statement.SequenceName)
     {
         StartWith = statement.StartWith,
         MinValue = statement.MinValue,
         MaxValue = statement.MaxValue,
         IncrementBy = statement.IncrementBy,
         Cache = statement.Cache,
         Cycle = statement.Cycle
     });
 }
        public void CreateWithStartValue()
        {
            var seqName = ObjectName.Parse("APP.test_seq1");
            var statement = new CreateSequenceStatement(seqName) {
                StartWith = SqlExpression.Constant(2)
            };

            statement.Execute(Query);

            var exists = Query.ObjectExists(DbObjectType.Sequence, seqName);

            Assert.IsTrue(exists);
        }
Esempio n. 6
0
        public void CreateWithStartValue()
        {
            var seqName   = ObjectName.Parse("APP.test_seq1");
            var statement = new CreateSequenceStatement(seqName)
            {
                StartWith = SqlExpression.Constant(2)
            };

            statement.Execute(Query);

            var exists = Query.ObjectExists(DbObjectType.Sequence, seqName);

            Assert.IsTrue(exists);
        }
        protected override void BuildStatement(SqlCodeObjectBuilder builder)
        {
            var seqName = ObjectName.Parse(SequenceName);
            var statement = new CreateSequenceStatement(seqName);

            if (IncrementBy != null)
                statement.IncrementBy = ExpressionBuilder.Build(IncrementBy);
            if (Cache != null)
                statement.Cache = ExpressionBuilder.Build(Cache);
            if (StartWith != null)
                statement.StartWith = ExpressionBuilder.Build(StartWith);
            if (MinValue != null)
                statement.MinValue = ExpressionBuilder.Build(MinValue);
            if (MaxValue != null)
                statement.MaxValue = ExpressionBuilder.Build(MaxValue);

            statement.Cycle = Cycle;

            builder.AddObject(statement);
        }
Esempio n. 8
0
        public static SqlStatement Create(PlSqlParser.CreateSequenceStatementContext context)
        {
            var seqName = Name.Object(context.objectName());

            var statement = new CreateSequenceStatement(seqName);

            var startWith = context.sequenceStartClause();
            if (startWith != null) {
                statement.StartWith = SqlExpression.Constant(Number.PositiveInteger(startWith.UNSIGNED_INTEGER()));
            }

            var specs = context.sequenceSpec();
            if (specs != null && specs.Length > 0) {
                foreach (var spec in specs) {
                    if (spec.INCREMENT() != null &&
                        spec.BY() != null) {
                        statement.IncrementBy = SqlExpression.Constant(Number.PositiveInteger(spec.UNSIGNED_INTEGER()));
                    } else if (spec.MAXVALUE() != null) {
                        statement.MaxValue = SqlExpression.Constant(Number.PositiveInteger(spec.UNSIGNED_INTEGER()));
                    } else if (spec.NOMAXVALUE() != null) {
                        statement.MaxValue = SqlExpression.Constant(null);
                    } else if (spec.MINVALUE() != null) {
                        statement.MinValue = SqlExpression.Constant(Number.PositiveInteger(spec.UNSIGNED_INTEGER()));
                    } else if (spec.NOMINVALUE() != null) {
                        statement.MinValue = SqlExpression.Constant(null);
                    } else if (spec.CACHE() != null) {
                        statement.Cache = SqlExpression.Constant(Number.PositiveInteger(spec.UNSIGNED_INTEGER()));
                    } else if (spec.NOCACHE() != null) {
                        statement.Cache = SqlExpression.Constant(null);
                    } else if (spec.CYCLE() != null) {
                        statement.Cycle = true;
                    } else if (spec.NOCYCLE() != null) {
                        statement.Cycle = false;
                    }
                }
            }

            return statement;
        }
Esempio n. 9
0
 protected virtual SqlStatement VisitCreateSequence(CreateSequenceStatement statement)
 {
     return new CreateSequenceStatement(statement.SequenceName) {
         StartWith = statement.StartWith,
         MinValue = statement.MinValue,
         MaxValue = statement.MaxValue,
         IncrementBy = statement.IncrementBy,
         Cache = statement.Cache,
         Cycle = statement.Cycle
     };
 }
Esempio n. 10
0
        protected override SqlStatement VisitCreateSequence(CreateSequenceStatement statement)
        {
            builder.AppendFormat("CREATE SEQUENCE {0}", statement.SequenceName);

            if (statement.StartWith != null)
                builder.AppendFormat(" START WITH {0}", statement.StartWith);
            if (statement.MinValue != null)
                builder.AppendFormat(" MIN VALUE {0}", statement.MinValue);
            if (statement.MaxValue != null)
                builder.AppendFormat(" MAX VALUE {0}", statement.MaxValue);
            if (statement.IncrementBy != null)
                builder.AppendFormat(" INCREMENT BY {0}", statement.IncrementBy);
            if (statement.Cache != null)
                builder.AppendFormat(" CACHE {0}", statement.Cache);
            if (statement.Cycle)
                builder.Append(" CYCLE");

            return base.VisitCreateSequence(statement);
        }