Package com.caucho.db.table

Examples of com.caucho.db.table.Table


    if (column == null)
      return Integer.MAX_VALUE;
   
    FromItem fromItem = fromList.get(fromList.size() - 1);

    Table table = fromItem.getTable();

    column = table.getColumn(_column);

    if (column == null)
      return 100 * 100 * 100;
    else if (column.isPrimaryKey())
      return 100;
View Full Code Here


  {
    if (_table == null) {
      for (int i = 0; i < fromItems.size(); i++) {
        FromItem fromItem = fromItems.get(i);

        Table table = fromItem.getTable();

        Column column = table.getColumn(_column);

        if (column != null)
          return column;
      }

      return null;
    }
    else {
      for (int i = 0; i < fromItems.size(); i++) {
        FromItem fromItem = fromItems.get(i);

        if (_table.equals(fromItem.getName())) {
          Table table = fromItem.getTable();

          return table.getColumn(_column);
        }
      }
     
      return null;
    }
View Full Code Here

    String tableName = parseIdentifier();
   
    if (tableName.equalsIgnoreCase("DUAL"))
      return null;

    Table table = _database.getTable(tableName);

    if (table == null)
      throw error(L.l("'{0}' is an unknown table.  'FROM table' requires an existing table.", tableName));

    String name = table.getName();

    int token = scanToken();
    if (token == AS)
      name = parseIdentifier();
    else if (token == IDENTIFIER)
View Full Code Here

      throw error(L.l("expected INTO at `{0}'", tokenName(token)));

    if ((token = scanToken()) != IDENTIFIER)
      throw error(L.l("expected identifier at `{0}'", tokenName(token)));

    Table table = _database.getTable(_lexeme);

    if (table == null)
      throw error(L.l("unknown table `{0}'", tokenName(token)));

    FromItem fromItem = new FromItem(table, table.getName());
    FromItem[] fromList = new FromItem[] { fromItem };

    ArrayList<Column> columns = new ArrayList<Column>();

    if ((token = scanToken()) == '(') {
      do {
        String columnName = parseIdentifier();

        Column column = table.getColumn(columnName);

        if (column == null)
          throw new SQLException(L.l("`{0}' is not a valid column in {1}",
                                     columnName, table.getName()));
        columns.add(column);
      } while ((token = scanToken()) == ',');

      if (token != ')')
        throw error(L.l("expected ')' at `{0}'", tokenName(token)));

      token = scanToken();
    }
    else {
      Column []columnArray = table.getColumns();

      for (int i = 0; i < columnArray.length; i++)
        columns.add(columnArray[i]);
    }
View Full Code Here

      throw error(L.l("expected FROM at `{0}'", tokenName(token)));

    if ((token = scanToken()) != IDENTIFIER)
      throw error(L.l("expected identifier at `{0}'", tokenName(token)));

    Table table = _database.getTable(_lexeme);

    if (table == null)
      throw error(L.l("unknown table `{0}'", tokenName(token)));

    DeleteQuery query = new DeleteQuery(_database, _sql, table);
View Full Code Here

    int token;

    if ((token = scanToken()) != IDENTIFIER)
      throw error(L.l("expected identifier at '{0}'", tokenName(token)));

    Table table = _database.getTable(_lexeme);

    if (table == null)
      throw error(L.l("unknown table '{0}'", tokenName(token)));

    ValidateQuery query = new ValidateQuery(_database, _sql, table);
View Full Code Here

    if ((token = scanToken()) != IDENTIFIER)
      throw error(L.l("expected identifier at `{0}'", tokenName(token)));

    String name = _lexeme;

    Table table = _database.getTable(name);

    if (table == null)
      throw error(L.l("`{0}' is an unknown table in INSERT.", name));

    if ((token = scanToken()) != SET)
View Full Code Here

   * Gets a table.
   */
  public Table getTable(String name)
  {
    synchronized (_tables) {
      Table table = _tables.get(name);

      if (table != null)
        return table;
     
      Path dir = _dir;
   
      if (dir == null)
        return null;

      try {
        table = Table.loadFromFile(this, name);

        if (table == null)
          return null;

        table.setFlushDirtyBlocksOnCommit(_isFlushDirtyBlocksOnCommit);
        table.init();

        _tables.put(name, table);

        return table;
      } catch (Exception e) {
View Full Code Here

   * Drops a table.
   */
  public void dropTable(String name)
    throws SQLException
  {
    Table table = null;

    synchronized (this) {
      table = getTable(name);
     
      if (table == null)
        throw new SQLException(L.l("Table {0} does not exist.  DROP TABLE can only drop an existing table.",
                                   name));

      _tables.remove(name);

      _cachedQueries.clear();
    }

    table.remove();
  }
View Full Code Here

    if (tableName == null) {
      if ("resin_oid".equals(columnName))
        return new OidExpr(fromItems[0], fromItems[0].getTable(), 0);

      for (int i = 0; i < fromItems.length; i++) {
        Table table = fromItems[i].getTable();

        int columnIndex = table.getColumnIndex(columnName);

        if (columnIndex >= 0) {
          Column column = table.getColumn(columnName);

          return new IdExpr(fromItems[i], column);
        }
      }

      Expr expr = bindParent(tableName, columnName);
      if (expr != null) {
        return expr;
      }

      throw new SQLException(L.l("`{0}' is an unknown column.", columnName));
    }
    else {
      for (int i = 0; i < fromItems.length; i++) {
        if (tableName.equals(fromItems[i].getName())) {
          Table table = fromItems[i].getTable();

          if ("resin_oid".equals(columnName))
            return new OidExpr(fromItems[i], table, i);

          int columnIndex = table.getColumnIndex(columnName);

          if (columnIndex < 0) {
            Expr expr = bindParent(tableName, columnName);
            if (expr != null)
              return expr;

            throw new SQLException(L.l("`{0}' is an unknown column in \n  {1}.",
                                       columnName, _sql));
          }

          Column column = table.getColumn(columnName);

          return new IdExpr(fromItems[i], column);
        }
      }
View Full Code Here

TOP

Related Classes of com.caucho.db.table.Table

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.