Exemplo n.º 1
0
        protected override void OutputIdentifier(
            string identifier,
            StringBuilder output,
            string sourceSql,
            ref int pos)
        {
            int num = pos;

            TextScanner.SkipWhiteSpaces(sourceSql, ref num);
            if (TextScanner.Pass('(', sourceSql, ref num))
            {
                TextScanner.SkipWhiteSpaces(sourceSql, ref num);
                if (TextScanner.Pass(')', sourceSql, ref num) && string.Equals(identifier, "GETDATE", StringComparison.InvariantCultureIgnoreCase))
                {
                    pos = num;
                    output.Append("SYSDATE ");
                }
                else
                {
                    base.OutputIdentifier(identifier, output, sourceSql, ref pos);
                }
            }
            else if (InDbOracleDatabase.IsReservedWord(identifier))
            {
                base.OutputIdentifier(identifier, output, sourceSql, ref pos);
            }
            else
            {
                this.OutputQualifiedIdentifier(identifier, output, sourceSql, ref pos);
            }
        }
Exemplo n.º 2
0
        public string Run(string sourceSql)
        {
            StringBuilder output = new StringBuilder();
            int           num    = 0;
            int           pos    = 0;

            while (pos <= sourceSql.Length)
            {
                this.PassWhiteSpaces(output, sourceSql, ref pos);
                if (pos < sourceSql.Length)
                {
                    if (TextScanner.Pass('?', sourceSql, ref pos))
                    {
                        this.OutputQuestionMark(num++, output, sourceSql, ref pos);
                    }
                    else
                    {
                        string str;
                        if (TextScanner.PassQuoted(ref str, '\'', sourceSql, ref pos))
                        {
                            this.OutputStringLiteral(str, output, sourceSql, ref pos);
                        }
                        else if (TextScanner.PassQuoted(ref str, '"', sourceSql, ref pos))
                        {
                            this.OutputQualifiedIdentifier(str, output, sourceSql, ref pos);
                        }
                        else if (this.PassQuoted(ref str, '[', ']', sourceSql, ref pos))
                        {
                            this.OutputQualifiedIdentifier(str, output, sourceSql, ref pos);
                        }
                        else if (TextScanner.PassIdentifier(ref str, sourceSql, ref pos))
                        {
                            this.OutputIdentifier(str, output, sourceSql, ref pos);
                        }
                        else
                        {
                            output.Append(sourceSql[pos++]);
                        }
                    }
                }
                else
                {
                    break;
                }
            }
            return(output.ToString());
        }