Search in sources :

Example 1 with BestRowIdentifier

use of net.sourceforge.squirrel_sql.fw.sql.dbobj.BestRowIdentifier in project tdq-studio-se by Talend.

the class RowIdsTab method getDataSet.

public DataSet getDataSet() throws Exception {
    INode node = getNode();
    if (node == null) {
        return null;
    }
    if (node instanceof TableNode) {
        TableNode tableNode = (TableNode) node;
        BestRowIdentifier[] rowIds = node.getSession().getMetaData().getBestRowIdentifier(tableNode.getTableInfo());
        Comparable[][] data = new Comparable[rowIds.length][];
        int index = 0;
        for (BestRowIdentifier rowId : rowIds) {
            Comparable[] row = new Comparable[COLUMN_LABELS.length];
            data[index++] = row;
            int i = 0;
            row[i++] = rowId.getScope();
            row[i++] = rowId.getColumnName();
            row[i++] = rowId.getSQLDataType();
            row[i++] = rowId.getTypeName();
            row[i++] = rowId.getPrecision();
            row[i++] = rowId.getScale();
            row[i++] = rowId.getPseudoColumn();
            if (i != COLUMN_LABELS.length)
                throw new RuntimeException(Messages.getString("RowIdsTab.RuntimeException"));
        }
        DataSet dataSet = new DataSet(COLUMN_LABELS, data);
        return dataSet;
    }
    return null;
}
Also used : INode(net.sourceforge.sqlexplorer.dbstructure.nodes.INode) DataSet(net.sourceforge.sqlexplorer.dataset.DataSet) TableNode(net.sourceforge.sqlexplorer.dbstructure.nodes.TableNode) BestRowIdentifier(net.sourceforge.squirrel_sql.fw.sql.dbobj.BestRowIdentifier)

Aggregations

DataSet (net.sourceforge.sqlexplorer.dataset.DataSet)1 INode (net.sourceforge.sqlexplorer.dbstructure.nodes.INode)1 TableNode (net.sourceforge.sqlexplorer.dbstructure.nodes.TableNode)1 BestRowIdentifier (net.sourceforge.squirrel_sql.fw.sql.dbobj.BestRowIdentifier)1