示例#1
0
        protected void AddFunction(ASTNodeList newNodes, string functionName, List <IASTNode> functionParameters)
        {
            IASTNode oraFunctionNode = NodeFactory.CreateNode(functionName, false);

            AddFunctionParameters(functionParameters, oraFunctionNode);

            newNodes.Add(oraFunctionNode);
        }
示例#2
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"));
        }
示例#3
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);
        }
示例#4
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);
        }
示例#5
0
        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);
            }
        }
示例#6
0
 private void CreateSpearatorNodes(ASTNodeList newNodes)
 {
     newNodes.Add(NodeFactory.CreateNode("||"));
     newNodes.Add(NodeFactory.CreateNode("'-'"));
     newNodes.Add(NodeFactory.CreateNode("||"));
 }