Exemple #1
0
        public static SqlStatement Alter(PlSqlParser.AlterUserStatementContext context)
        {
            var userName = context.userName().GetText();

            var actions = new List<IAlterUserAction>();

            foreach (var actionContext in context.alterUserAction()) {
                if (actionContext.alterUserIdAction() != null) {
                    actions.Add(SetPassword(actionContext.alterUserIdAction()));
                } else if (actionContext.setAccountAction() != null) {
                    actions.Add(SetAccount(actionContext.setAccountAction()));
                } else if (actionContext.setRoleAction() != null) {
                    actions.Add(SetRole(actionContext.setRoleAction()));
                }
            }

            if (actions.Count == 1)
                return new AlterUserStatement(userName, actions[0]);

            var seq = new SequenceOfStatements();
            foreach (var action in actions) {
                seq.Statements.Add(new AlterUserStatement(userName, action));
            }

            return seq;
        }
Exemple #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);
        }
Exemple #3
0
        public static string Simple(PlSqlParser.GranteeNameContext context)
        {
            if (context.userName() != null)
                return Simple(context.userName());

            return Simple(context.roleName());
        }