コード例 #1
0
        public override void Translate(IATranslator translator, ASTNodeList newNodes, ASTNodeList subNodes, IASTNodeFactory nodeFactory)
        {
            Translator  = translator;
            NodeFactory = nodeFactory;

            AddFunction(newNodes, "getdate", new List <IASTNode>());
        }
コード例 #2
0
        protected void AddFunction(ASTNodeList newNodes, string functionName, List <IASTNode> functionParameters)
        {
            IASTNode oraFunctionNode = NodeFactory.CreateNode(functionName, false);

            AddFunctionParameters(functionParameters, oraFunctionNode);

            newNodes.Add(oraFunctionNode);
        }
コード例 #3
0
        protected IASTNode CreateFunctionParameterNodeWithSubNodes(IASTNode functionParameterNode)
        {
            ASTNodeList tmpSubNodes = new ASTNodeList();

            Translator.TranslateSubNodes(tmpSubNodes, functionParameterNode);

            return(tmpSubNodes[0]);
        }
コード例 #4
0
        private void CreateSubStringNode(ASTNodeList newNodes, IASTNode parameter, string start, string length)
        {
            List <IASTNode> functionParameters = new List <IASTNode>
            {
                CreateFunctionParameterNodeWithSubNodes(parameter),
                CreateFunctionParameterNode(start),
                CreateFunctionParameterNode(length)
            };

            AddFunction(newNodes, "substr", functionParameters);
        }
コード例 #5
0
ファイル: ATranslator.cs プロジェクト: radtek/ACopy
        public ASTNodeList Translate(ASTNodeList nodes)
        {
            ASTNodeList newNodes = new ASTNodeList();

            foreach (var node in nodes)
            {
                TranslateSubNodes(newNodes, node);
            }

            return(newNodes);
        }
コード例 #6
0
 private void CreateNodesForGuidParts(ASTNodeList newNodes, IASTNode parameter)
 {
     CreateSubStringNode(newNodes, parameter, "1", "8");
     CreateSpearatorNodes(newNodes);
     CreateSubStringNode(newNodes, parameter, "9", "4");
     CreateSpearatorNodes(newNodes);
     CreateSubStringNode(newNodes, parameter, "13", "4");
     CreateSpearatorNodes(newNodes);
     CreateSubStringNode(newNodes, parameter, "17", "4");
     CreateSpearatorNodes(newNodes);
     CreateSubStringNode(newNodes, parameter, "21", "12");
 }
コード例 #7
0
        public override void Translate(IATranslator translator, ASTNodeList newNodes, ASTNodeList subNodes, IASTNodeFactory nodeFactory)
        {
            // Translated to to_date('19000101 00:00:00', 'yyyymmdd hh24:mi:ss')
            Translator  = translator;
            NodeFactory = nodeFactory;

            List <IASTNode> functionParameters = new List <IASTNode>
            {
                nodeFactory.CreateNode("'19000101 00:00:00'", false),
                nodeFactory.CreateNode("'yyyymmdd hh24:mi:ss'", false)
            };

            AddFunction(newNodes, "to_date", functionParameters);
        }
コード例 #8
0
        public override void Translate(IATranslator translator, ASTNodeList newNodes, ASTNodeList subNodes, IASTNodeFactory nodeFactory)
        {
            // MONTHADD(3, today) => add_months(today, 3)
            Translator  = translator;
            NodeFactory = nodeFactory;

            List <IASTNode> functionParameters = new List <IASTNode>
            {
                CreateFunctionParameterNodeWithSubNodes(subNodes[3]),
                CreateFunctionParameterNodeWithSubNodes(subNodes[1])
            };

            AddFunction(newNodes, "add_months", functionParameters);
        }
コード例 #9
0
        private void AddDecodeFunction(ASTNodeList newNodes, IASTNode parameter)
        {
            List <IASTNode> parameters = new List <IASTNode>
            {
                parameter,
                CreateFunctionParameterNode("' '"),
                CreateFunctionParameterNode("0.00"),
                parameter
            };

            AddFunction(newNodes, "decode", parameters);
            newNodes.Add(NodeFactory.CreateNode("as"));
            AddFunction(newNodes, "number", CreateFunctionParameterNode("20"));
        }
コード例 #10
0
        public override void Translate(IATranslator translator, ASTNodeList newNodes, ASTNodeList subNodes, IASTNodeFactory nodeFactory)
        {
            // IFNULL(somecol, 0) => nvl(somecol, 0)
            Translator  = translator;
            NodeFactory = nodeFactory;

            List <IASTNode> functionParameters = new List <IASTNode>
            {
                CreateFunctionParameterNodeWithSubNodes(subNodes[1]),
                CreateFunctionParameterNodeWithSubNodes(subNodes[3])
            };

            AddFunction(newNodes, "nvl", functionParameters);
        }
コード例 #11
0
        public override void Translate(IATranslator translator, ASTNodeList newNodes, ASTNodeList subNodes, IASTNodeFactory nodeFactory)
        {
            // Translated to convert(datetime, '19000101 00:00:00:000', 9)
            Translator  = translator;
            NodeFactory = nodeFactory;

            List <IASTNode> functionParameters = new List <IASTNode>
            {
                nodeFactory.CreateNode("datetime", false),
                nodeFactory.CreateNode("'19000101 00:00:00:000'", false),
                nodeFactory.CreateNode("9", false)
            };

            AddFunction(newNodes, "convert", functionParameters);
        }
コード例 #12
0
        public override void Translate(IATranslator translator, ASTNodeList newNodes, ASTNodeList subNodes, IASTNodeFactory nodeFactory)
        {
            // The guid2str function is pretty ugly in Oracle. A call like guid2str(guid_col) becomes:
            //     lower(substr(guid_col,1,8) || '-' || substr(guid_col,9,4) || '-' || substr(guid_col,13,4) || '-' || substr(guid_col,17,4) || '-' || substr(guid_col,21,12))
            Translator  = translator;
            NodeFactory = nodeFactory;

            IASTNode newNode = NodeFactory.CreateNode("lower", false);

            newNode.SubNodes.Add(NodeFactory.CreateNode(ASTStartParenthesesNode.KeyWord, false));
            newNode.SubNodes.Add(NodeFactory.CreateFunctionParameterNode());
            newNode.SubNodes.Add(NodeFactory.CreateNode(ASTEndParenthesesNode.KeyWord));

            CreateNodesForGuidParts(newNode.SubNodes[1].SubNodes, subNodes[1]);

            newNodes.Add(newNode);
        }
コード例 #13
0
        public override void Translate(IATranslator translator, ASTNodeList newNodes, ASTNodeList subNodes, IASTNodeFactory nodeFactory)
        {
            // TO_FLOAT('123') => cast(decode('123', ' ', 0.00, '123') as number(30,8) )
            Translator  = translator;
            NodeFactory = nodeFactory;

            IASTNode newNode = NodeFactory.CreateNode("cast", false);

            newNode.SubNodes.Add(NodeFactory.CreateNode(ASTStartParenthesesNode.KeyWord, false));
            newNode.SubNodes.Add(NodeFactory.CreateFunctionParameterNode());
            newNode.SubNodes.Add(NodeFactory.CreateNode(ASTEndParenthesesNode.KeyWord));

            IASTNode parameter = CreateFunctionParameterNodeWithSubNodes(subNodes[1]);

            AddDecodeFunction(newNode.SubNodes[1].SubNodes, parameter);

            newNodes.Add(newNode);
        }
コード例 #14
0
        public override void Translate(IATranslator translator, ASTNodeList newNodes, ASTNodeList subNodes, IASTNodeFactory nodeFactory)
        {
            // DAYADD(3, day_col) => dateadd(dd, 3, day_col)
            Translator  = translator;
            NodeFactory = nodeFactory;

            IASTNode unitParameter = NodeFactory.CreateFunctionParameterNode();

            unitParameter.SubNodes.Add(NodeFactory.CreateNode("dd", false));

            List <IASTNode> functionParameters = new List <IASTNode>
            {
                unitParameter,
                CreateFunctionParameterNodeWithSubNodes(subNodes[1]),
                CreateFunctionParameterNodeWithSubNodes(subNodes[3])
            };

            AddFunction(newNodes, "dateadd", functionParameters);
        }
コード例 #15
0
        public override void Translate(IATranslator translator, ASTNodeList newNodes, ASTNodeList subNodes, IASTNodeFactory nodeFactory)
        {
            // MONTHADD(3, today) => dateadd(mm, 3, today)
            Translator  = translator;
            NodeFactory = nodeFactory;

            IASTNode mmParameter = NodeFactory.CreateFunctionParameterNode();

            mmParameter.SubNodes.Add(NodeFactory.CreateNode("mm", false));

            List <IASTNode> functionParameters = new List <IASTNode>
            {
                mmParameter,
                CreateFunctionParameterNodeWithSubNodes(subNodes[1]),
                CreateFunctionParameterNodeWithSubNodes(subNodes[3])
            };

            AddFunction(newNodes, "dateadd", functionParameters);
        }
コード例 #16
0
ファイル: ATranslator.cs プロジェクト: radtek/ACopy
        public void TranslateSubNodes(ASTNodeList newNodes, IASTNode fromNode)
        {
            IASTNodeTranslator nodeTranslator;

            if (!string.IsNullOrEmpty(fromNode.Text) && NodeTranslators.TryGetValue(fromNode.Text, out nodeTranslator)) // Text property may add a space at the end, depending on the setting of AddSpace, so need to be trimmed
            {
                nodeTranslator.Translate(this, newNodes, fromNode.SubNodes, NodeFactory);
                return;
            }

            IASTNode newNode = fromNode.CloneWithoutSubNodes();

            newNodes.Add(newNode);
            if (fromNode.SubNodes == null || fromNode.SubNodes.Count == 0)
            {
                return;
            }

            foreach (var node in fromNode.SubNodes)
            {
                TranslateSubNodes(newNode.SubNodes, node);
            }
        }
コード例 #17
0
ファイル: ASTNodeBase.cs プロジェクト: radtek/ACopy
 public void ResetSubNodes()
 {
     _subNodes = null;
 }
コード例 #18
0
 protected void AddFunction(ASTNodeList newNodes, string functionName, IASTNode functionParameter)
 {
     AddFunction(newNodes, functionName, new List <IASTNode> {
         functionParameter
     });
 }
コード例 #19
0
 private void CreateSpearatorNodes(ASTNodeList newNodes)
 {
     newNodes.Add(NodeFactory.CreateNode("||"));
     newNodes.Add(NodeFactory.CreateNode("'-'"));
     newNodes.Add(NodeFactory.CreateNode("||"));
 }
コード例 #20
0
 public abstract void Translate(IATranslator translator, ASTNodeList newNodes, ASTNodeList subNodes, IASTNodeFactory nodeFactory);