public override SqlExpression VisitTrimFunction(PlSqlParser.TrimFunctionContext context)
        {
            var arg1 = SqlParseExpression.Build(Context, context.concatenationWrapper());
            var part = "both";

            if (context.LEADING() != null)
            {
                part = "leading";
            }
            else if (context.TRAILING() != null)
            {
                part = "trailing";
            }
            else if (context.BOTH() != null)
            {
                part = "both";
            }

            var toTrim = " ";

            if (context.quoted_string() != null)
            {
                toTrim = SqlParseInputString.AsNotQuoted(context.quoted_string());
            }

            var arg2 = SqlExpression.Constant(SqlObject.String(part));
            var arg3 = SqlExpression.Constant(SqlObject.String(toTrim));

            return(SqlExpression.Function("SQL_TRIM", new SqlExpression[] { arg1, arg2, arg3 }));
        }
        public override SqlExpression VisitTimeStampFunction(PlSqlParser.TimeStampFunctionContext context)
        {
            SqlExpression arg;

            if (context.bind_variable() != null)
            {
                arg = SqlExpression.Variable(SqlParseUtil.Name.Variable(context.bind_variable()));
            }
            else if (context.argString != null)
            {
                arg = SqlExpression.Constant(SqlObject.String(SqlParseInputString.AsNotQuoted(context.argString)));
            }
            else
            {
                throw new ParseCanceledException("Invalid argument in a TIMESTAMP implicit function");
            }

            SqlExpression tzArg = null;

            if (context.tzString != null)
            {
                tzArg = SqlExpression.Constant(SqlObject.String(SqlParseInputString.AsNotQuoted(context.tzString)));
            }

            var args = tzArg != null
                ? new SqlExpression[] { arg, tzArg }
                : new SqlExpression[] { arg };

            return(SqlExpression.Function("TOTIMESTAMP", args));
        }
        public override SqlExpression VisitDateImplicitConvert(PlSqlParser.DateImplicitConvertContext context)
        {
            var s = SqlParseInputString.AsNotQuoted(context.quoted_string());

            return(SqlExpression.Function("CAST",
                                          new SqlExpression[] {
                SqlExpression.Constant(SqlObject.String(s)),
                SqlExpression.Constant(SqlObject.String("DATE"))
            }));
        }
        public override SqlExpression VisitConstantString(PlSqlParser.ConstantStringContext context)
        {
            var value = SqlParseInputString.AsNotQuoted(context.quoted_string());

            return(SqlExpression.Constant(SqlObject.String(value)));
        }