public override void Translate(IATranslator translator, ASTNodeList newNodes, ASTNodeList subNodes, IASTNodeFactory nodeFactory) { Translator = translator; NodeFactory = nodeFactory; AddFunction(newNodes, "getdate", new List <IASTNode>()); }
protected void AddFunction(ASTNodeList newNodes, string functionName, List <IASTNode> functionParameters) { IASTNode oraFunctionNode = NodeFactory.CreateNode(functionName, false); AddFunctionParameters(functionParameters, oraFunctionNode); newNodes.Add(oraFunctionNode); }
protected IASTNode CreateFunctionParameterNodeWithSubNodes(IASTNode functionParameterNode) { ASTNodeList tmpSubNodes = new ASTNodeList(); Translator.TranslateSubNodes(tmpSubNodes, functionParameterNode); return(tmpSubNodes[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); }
public ASTNodeList Translate(ASTNodeList nodes) { ASTNodeList newNodes = new ASTNodeList(); foreach (var node in nodes) { TranslateSubNodes(newNodes, node); } return(newNodes); }
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"); }
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); }
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); }
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")); }
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); }
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); }
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); }
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); }
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); }
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); }
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); } }
public void ResetSubNodes() { _subNodes = null; }
protected void AddFunction(ASTNodeList newNodes, string functionName, IASTNode functionParameter) { AddFunction(newNodes, functionName, new List <IASTNode> { functionParameter }); }
private void CreateSpearatorNodes(ASTNodeList newNodes) { newNodes.Add(NodeFactory.CreateNode("||")); newNodes.Add(NodeFactory.CreateNode("'-'")); newNodes.Add(NodeFactory.CreateNode("||")); }
public abstract void Translate(IATranslator translator, ASTNodeList newNodes, ASTNodeList subNodes, IASTNodeFactory nodeFactory);