use of com.cubrid.cubridmanager.core.cubrid.table.task.GetRecordCountTask in project cubrid-manager by CUBRID.
the class ColumnSelectCountAction method run.
/**
* @see org.eclipse.jface.action.Action#run()
*/
public void run() {
BusyIndicator.showWhile(Display.getDefault(), new Runnable() {
public void run() {
Object[] obj = getSelectedObj();
if (!isSupported(obj)) {
setEnabled(false);
return;
}
ISchemaNode column = (ISchemaNode) obj[0];
ISchemaNode table = (ISchemaNode) column.getParent().getParent();
String columnName = column.getName().split(",")[0];
if ("".equals(columnName)) {
// FIXME
return;
}
CubridDatabase db = table.getDatabase();
DatabaseInfo dbInfo = db.getDatabaseInfo();
GetRecordCountTask task = new GetRecordCountTask(dbInfo);
int count = task.getRecordCount(table.getName(), columnName, null);
String[] bindings = new String[] { columnName, table.getName(), String.valueOf(count) };
if (count > 1) {
message = Messages.bind(Messages.columnSelectCountResult2, bindings);
} else {
message = Messages.bind(Messages.columnSelectCountResult1, bindings);
}
}
});
CommonUITool.openInformationBox(Messages.selectCountTitle, message);
}
use of com.cubrid.cubridmanager.core.cubrid.table.task.GetRecordCountTask in project cubrid-manager by CUBRID.
the class TableSelectCountAction method doRun.
/**
* Perform select
*
* @param table
*/
private void doRun(final ISchemaNode table) {
BusyIndicator.showWhile(Display.getDefault(), new Runnable() {
public void run() {
CubridDatabase db = table.getDatabase();
DatabaseInfo dbInfo = db.getDatabaseInfo();
GetRecordCountTask task = new GetRecordCountTask(dbInfo);
int count = task.getRecordCount(table.getName(), null);
if (count > 1) {
message = Messages.bind(Messages.selectCountResult2, table.getName(), count);
} else {
message = Messages.bind(Messages.selectCountResult1, table.getName(), count);
}
}
});
CommonUITool.openInformationBox(Messages.selectCountTitle, message);
}
use of com.cubrid.cubridmanager.core.cubrid.table.task.GetRecordCountTask in project cubrid-manager by CUBRID.
the class ConstraintComparator method getAlterAutoIncrementDDL.
/**
*
* Depending the change auto increment
*
* @param tableName String the given table name
* @param columnName String the given column name
* @param startWith String the given startWith
* @param incrementby String the given incrementBy
* @param minValue String the given columnName
* @return String a string that indicates the DDL of alter auto increment
*/
public String getAlterAutoIncrementDDL(String tableName, String columnName) {
StringBuilder ddl = new StringBuilder();
int autoIncrementSeed = new GetRecordCountTask(databaseInfo).getRecordCount(tableName, columnName, null) + 1;
boolean isSupportAlterAutoIncrement = CompatibleUtil.isAfter840(databaseInfo);
if (isSupportAlterAutoIncrement) {
ddl.append("ALTER TABLE ").append(QuerySyntax.escapeKeyword(tableName)).append(" AUTO_INCREMENT=").append(autoIncrementSeed).append(endLineChar).append(StringUtil.NEWLINE);
return ddl.toString();
} else {
ddl.append("--NotSupportAlterAutoIncrement");
return ddl.toString();
}
}
Aggregations