use of org.jkiss.dbeaver.ext.generic.model.GenericDataSource in project dbeaver by serge-rider.
the class SQLiteTableManager method addObjectRenameActions.
@Override
protected void addObjectRenameActions(List<DBEPersistAction> actions, ObjectRenameCommand command) {
final GenericDataSource dataSource = command.getObject().getDataSource();
actions.add(new SQLDatabasePersistAction("Rename table", //$NON-NLS-1$
"ALTER TABLE " + command.getObject().getFullyQualifiedName(DBPEvaluationContext.DDL) + " RENAME TO " + //$NON-NLS-1$
DBUtils.getQuotedIdentifier(dataSource, command.getNewName())));
}
use of org.jkiss.dbeaver.ext.generic.model.GenericDataSource in project dbeaver by serge-rider.
the class NetezzaMetaModel method getProcedureDDL.
@Override
public String getProcedureDDL(DBRProgressMonitor monitor, GenericProcedure sourceObject) throws DBException {
GenericDataSource dataSource = sourceObject.getDataSource();
try (JDBCSession session = DBUtils.openMetaSession(monitor, dataSource, "Read Netezza procedure source")) {
try (JDBCPreparedStatement dbStat = session.prepareStatement("SELECT p.proceduresignature,p.returns,p.proceduresource " + "FROM _v_procedure p " + "WHERE p.owner=? AND p.procedure=?")) {
dbStat.setString(1, sourceObject.getContainer().getName());
dbStat.setString(2, sourceObject.getName());
try (JDBCResultSet dbResult = dbStat.executeQuery()) {
if (dbResult.nextRow()) {
return "CREATE OR REPLACE PROCEDURE " + dbResult.getString(1) + " RETURNS " + dbResult.getString(2) + "LANGUAGE NZPLSQL AS BEGIN_PROC\n" + dbResult.getString(3) + "\nEND_PROC;";
}
return "-- Netezza procedure source not found";
}
}
} catch (SQLException e) {
throw new DBException(e, dataSource);
}
}
use of org.jkiss.dbeaver.ext.generic.model.GenericDataSource in project dbeaver by serge-rider.
the class NetezzaMetaModel method getViewDDL.
public String getViewDDL(DBRProgressMonitor monitor, GenericTable sourceObject) throws DBException {
GenericDataSource dataSource = sourceObject.getDataSource();
try (JDBCSession session = DBUtils.openMetaSession(monitor, dataSource, "Read Netezza view source")) {
try (JDBCPreparedStatement dbStat = session.prepareStatement("SELECT v.definition " + "FROM _v_view v, _v_objs_owned o " + "WHERE v.objid = o.objid AND o.DATABASE=? AND v.VIEWNAME=?")) {
dbStat.setString(1, sourceObject.getContainer().getName());
dbStat.setString(2, sourceObject.getName());
try (JDBCResultSet dbResult = dbStat.executeQuery()) {
if (dbResult.nextRow()) {
return "CREATE OR REPLACE VIEW " + sourceObject.getName() + " AS\n" + dbResult.getString(1);
}
return "-- Netezza view definition not found";
}
}
} catch (SQLException e) {
throw new DBException(e, dataSource);
}
}
use of org.jkiss.dbeaver.ext.generic.model.GenericDataSource in project dbeaver by serge-rider.
the class TeradataMetaModel method getTableDDL.
@Override
public String getTableDDL(DBRProgressMonitor monitor, GenericTable sourceObject) throws DBException {
GenericDataSource dataSource = sourceObject.getDataSource();
boolean isView = sourceObject.isView();
try (JDBCSession session = DBUtils.openMetaSession(monitor, dataSource, "Read Teradata object DDL")) {
try (JDBCPreparedStatement dbStat = session.prepareStatement("SHOW " + (isView ? "VIEW" : "TABLE") + " " + sourceObject.getFullyQualifiedName(DBPEvaluationContext.DDL))) {
try (JDBCResultSet dbResult = dbStat.executeQuery()) {
StringBuilder sql = new StringBuilder();
while (dbResult.nextRow()) {
sql.append(dbResult.getString(1));
}
return sql.toString();
}
}
} catch (SQLException e) {
throw new DBException(e, dataSource);
}
}
Aggregations