-2

We are trying to generate upsert statement of phoenix with the logic we want to give in xml file . We are thinking of using antlr or string templates , Please let us know which one to use better . or any other approach we can use Input data is thought of be given from xml file. Antlr or string template will read that xml and then generate the upsert statements. IN xml we thought of

 <Query>
                    <Maintable>Employee</Maintable>
                    <Jointable>Employer</Jointable>
                    <joinType>INNER</joinType>

                    <columnsToSelect>"ID","Name","Employee_SHRT_NME"</columnsToSelect>
    </Query>
gaurav
  • 2,214
  • 6
  • 21
  • 26
  • Reason for downvote: http://stackoverflow.com/help/on-topic "Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.". I've flagged this, though it is quite interesting question (just not for SO) – Filip Malczak May 19 '15 at 09:02
  • Be more specific. Is there an example? Inputdata? Outputdata? What do you have so far? – wumpz May 19 '15 at 09:03
  • Input data is thought of be given from xml file. Antlr or string template will read that xml and then generate the upsert statements. IN xml we thought of – gaurav May 19 '15 at 09:05

1 Answers1

1

To read this xml, use a simple xml parser. To translate it to SQL you may write a small template in StringTemplate that takes all variable parts as arguments, e.g.:

 SqlStatement(Maintable, Jointable, JoinType, Colums, VALUES) ::= <<
   INSERT INTO <Maintable> <JoinType> JOIN <Jointable> (Columns) VALUES <Values>
 >>
CoronA
  • 6,648
  • 2
  • 23
  • 47