Package net.sf.jsqlparser.statement.select

Examples of net.sf.jsqlparser.statement.select.Select


    } catch (final JSQLParserException ex) {
      LOG.info("JSQLParserException");
    }

    if (statement instanceof Select) {
      final Select selectStatement = (Select) statement;
      final String queryName = SystemParameters.getString(map, "DIP_QUERY_NAME");
      final SQLVisitor parsedQuery = new SQLVisitor(queryName);

      // visit whole SELECT statement
      parsedQuery.visit(selectStatement);
View Full Code Here


                {if (true) return table;}
    throw new Error("Missing return statement in function");
  }

  final public Select Select() throws ParseException {
        Select select = new Select();
        SelectBody selectBody = null;
        List with = null;
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case K_WITH:
      with = WithList();
                            select.setWithItemsList(with);
      break;
    default:
      jj_la1[22] = jj_gen;
      ;
    }
    selectBody = SelectBody();
                select.setSelectBody(selectBody);
                {if (true) return select;}
    throw new Error("Missing return statement in function");
  }
View Full Code Here

    numTests = 0;
    time = System.currentTimeMillis();
    // measure the time to get the tables names from all the SELECTs parsed before
    for (Iterator iter = parsedSelects.iterator(); iter.hasNext();) {
      Select select = (Select) iter.next();
      if (select != null) {
        numTests++;
        List tableListRetr = tablesNamesFinder.getTableList(select);
      }
    }
View Full Code Here

        String cols = getLine(in);
        String tables = getLine(in);
        String whereCols = getLine(in);
        String type = getLine(in);
        try {
          Select select = (Select) pm.parse(new StringReader(query));
          StringTokenizer tokenizer = new StringTokenizer(tables, " ");
          List tablesList = new ArrayList();
          while (tokenizer.hasMoreTokens()) {
            tablesList.add(tokenizer.nextToken());
          }
View Full Code Here

    // now you should use a class that implements StatementVisitor to decide what to do
    // based on the kind of the statement, that is SELECT or INSERT etc. but here we are only
    // interested in SELECTS

    if (statement instanceof Select) {
      Select selectStatement = (Select) statement;
      TablesNamesFinder tablesNamesFinder = new TablesNamesFinder();
      List<String> tableList = tablesNamesFinder.getTableList(selectStatement);
      assertEquals(6, tableList.size());
      int i = 1;
      for (Iterator iter = tableList.iterator(); iter.hasNext(); i++) {
View Full Code Here

    @Test
  public void testGetTableListWithAlias() throws Exception {
    String sql = "SELECT * FROM MY_TABLE1 as ALIAS_TABLE1";
    net.sf.jsqlparser.statement.Statement statement = pm.parse(new StringReader(sql));

    Select selectStatement = (Select) statement;
    TablesNamesFinder tablesNamesFinder = new TablesNamesFinder();
    List<String> tableList = tablesNamesFinder.getTableList(selectStatement);
    assertEquals(1, tableList.size());
    assertEquals("MY_TABLE1", (String) tableList.get(0));
  }
View Full Code Here

    @Test
  public void testGetTableListWithStmt() throws Exception {
    String sql = "WITH TESTSTMT as (SELECT * FROM MY_TABLE1 as ALIAS_TABLE1) SELECT * FROM TESTSTMT";
    net.sf.jsqlparser.statement.Statement statement = pm.parse(new StringReader(sql));

    Select selectStatement = (Select) statement;
    TablesNamesFinder tablesNamesFinder = new TablesNamesFinder();
    List<String> tableList = tablesNamesFinder.getTableList(selectStatement);
    assertEquals(1, tableList.size());
    assertEquals("MY_TABLE1", (String) tableList.get(0));
  }
View Full Code Here

    @Test
  public void testGetTableListWithLateral() throws Exception {
    String sql = "SELECT * FROM MY_TABLE1, LATERAL(select a from MY_TABLE2) as AL";
    net.sf.jsqlparser.statement.Statement statement = pm.parse(new StringReader(sql));

    Select selectStatement = (Select) statement;
    TablesNamesFinder tablesNamesFinder = new TablesNamesFinder();
    List<String> tableList = tablesNamesFinder.getTableList(selectStatement);
    assertEquals(2, tableList.size());
    assertTrue(tableList.contains("MY_TABLE1"));
    assertTrue(tableList.contains("MY_TABLE2"));
View Full Code Here

    @Test
  public void testCmplxSelectProblem() throws Exception {
    String sql = "SELECT cid, (SELECT name FROM tbl0 WHERE tbl0.id = cid) AS name, original_id AS bc_id FROM tbl WHERE crid = ? AND user_id is null START WITH ID = (SELECT original_id FROM tbl2 WHERE USER_ID = ?) CONNECT BY prior parent_id = id AND rownum = 1";
    net.sf.jsqlparser.statement.Statement statement = pm.parse(new StringReader(sql));

    Select selectStatement = (Select) statement;
    TablesNamesFinder tablesNamesFinder = new TablesNamesFinder();
    List<String> tableList = tablesNamesFinder.getTableList(selectStatement);
    assertEquals(3, tableList.size());
    assertTrue(tableList.contains("tbl0"));
        assertTrue(tableList.contains("tbl"));
View Full Code Here

  CCJSqlParserManager parserManager = new CCJSqlParserManager();

  @Test
  public void testVisit_PlainSelect_concat() throws JSQLParserException {
    String sql = "select a,b,c from test";
    Select select = (Select) parserManager.parse(new StringReader(sql));
    ConnectExpressionsVisitor instance = new ConnectExpressionsVisitor() {
      @Override
      protected BinaryExpression createBinaryExpression() {
        return new Concat();
      }
    };
    select.getSelectBody().accept(instance);

    assertEquals("SELECT a || b || c AS expr FROM test", select.toString());
  }
View Full Code Here

TOP

Related Classes of net.sf.jsqlparser.statement.select.Select

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.