コード例 #1
0
        public override SqlStatement VisitCreateUserStatement(PlSqlParser.CreateUserStatementContext context)
        {
            var    userName = context.userName().GetText();
            string arg;
            IUserIdentificationInfo id;

            if (context.byPassword() != null)
            {
                arg = SqlParseInputString.AsNotQuoted(context.byPassword().CHAR_STRING().GetText());
                id  = new PasswordIdentificationInfo(arg);
            }
            else if (context.externalId() != null)
            {
                arg = SqlParseInputString.AsNotQuoted(context.externalId().CHAR_STRING().GetText());
                throw new NotSupportedException("EXTERNAL identification not supported yet");
            }
            else if (context.globalId() != null)
            {
                arg = SqlParseInputString.AsNotQuoted(context.globalId().CHAR_STRING().GetText());
                throw new NotSupportedException("GLOBAL identification not supported yet");
            }
            else
            {
                throw new ParseCanceledException("Invalid identification option");
            }

            AddStatement(context, new CreateUserStatement(userName, id));
            return(base.VisitCreateUserStatement(context));
        }
コード例 #2
0
        public static SqlStatement Create(PlSqlParser.CreateUserStatementContext context)
        {
            var                   userName = context.userName().GetText();
            SqlExpression         arg;
            SqlIdentificationType type;

            if (context.byPassword() != null)
            {
                arg  = SqlExpression.Constant(InputString.AsNotQuoted(context.byPassword().CHAR_STRING().GetText()));
                type = SqlIdentificationType.Password;
            }
            else if (context.externalId() != null)
            {
                arg  = SqlExpression.Constant(InputString.AsNotQuoted(context.externalId().CHAR_STRING()));
                type = SqlIdentificationType.External;
            }
            else if (context.globalId() != null)
            {
                arg  = SqlExpression.Constant(InputString.AsNotQuoted(context.globalId().CHAR_STRING()));
                type = SqlIdentificationType.Global;
            }
            else
            {
                throw new ParseCanceledException();
            }

            var id = new SqlUserIdentifier(type, arg);

            return(new CreateUserStatement(userName, id));
        }