use of org.jkiss.dbeaver.model.struct.rdb.DBSProcedure in project dbeaver by dbeaver.
the class GenerateSQLContributor method CALL_GENERATOR.
@NotNull
public static SQLGenerator<DBSProcedure> CALL_GENERATOR(final List<DBSProcedure> entities) {
return new ProcedureAnalysisRunner(entities) {
@Override
protected void generateSQL(DBRProgressMonitor monitor, StringBuilder sql, DBSProcedure proc) throws DBException {
Collection<? extends DBSProcedureParameter> parameters = proc.getParameters(monitor);
DBPDataSource dataSource = proc.getDataSource();
if (dataSource instanceof SQLDataSource) {
SQLDataSource sqlDataSource = (SQLDataSource) dataSource;
SQLDialect sqlDialect = sqlDataSource.getSQLDialect();
sqlDialect.generateStoredProcedureCall(sql, proc, parameters);
}
}
};
}
use of org.jkiss.dbeaver.model.struct.rdb.DBSProcedure in project dbeaver by serge-rider.
the class SQLEditorHandlerRunProcedureConsole method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchWindow workbenchWindow = HandlerUtil.getActiveWorkbenchWindow(event);
SQLNavigatorContext navContext = null;
String procName = null;
ISelection currentSelection = HandlerUtil.getCurrentSelection(event);
List<DBSObject> selectedObjects = NavigatorUtils.getSelectedObjects(currentSelection);
List<DBSProcedure> entities = new ArrayList<>();
for (DBSObject object : selectedObjects) {
if (object instanceof DBSProcedure) {
DBSProcedure proc = (DBSProcedure) object;
procName = proc.getName();
entities.add(proc);
if (navContext == null) {
navContext = new SQLNavigatorContext(object);
}
}
}
if (navContext == null || navContext.getDataSourceContainer() == null) {
log.debug("No active datasource");
return null;
}
DBRRunnableWithResult<String> generator = SQLGeneratorContributor.CALL_GENERATOR(entities);
String title = "Stored procedures call";
if (entities.size() == 1 && !CommonUtils.isEmpty(procName)) {
title = procName + " call";
}
try {
openConsole(workbenchWindow, generator, navContext, title, false, currentSelection);
} catch (Exception e) {
DBWorkbench.getPlatformUI().showError("Open console", "Can open SQL editor", e);
}
return null;
}
use of org.jkiss.dbeaver.model.struct.rdb.DBSProcedure in project dbeaver by dbeaver.
the class SQLEditorHandlerRunProcedureConsole method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchWindow workbenchWindow = HandlerUtil.getActiveWorkbenchWindow(event);
SQLNavigatorContext navContext = null;
String procName = null;
ISelection currentSelection = HandlerUtil.getCurrentSelection(event);
List<DBSObject> selectedObjects = NavigatorUtils.getSelectedObjects(currentSelection);
List<DBSProcedure> entities = new ArrayList<>();
for (DBSObject object : selectedObjects) {
if (object instanceof DBSProcedure) {
DBSProcedure proc = (DBSProcedure) object;
procName = proc.getName();
entities.add(proc);
if (navContext == null) {
navContext = new SQLNavigatorContext(object);
}
}
}
if (navContext == null || navContext.getDataSourceContainer() == null) {
log.debug("No active datasource");
return null;
}
DBRRunnableWithResult<String> generator = SQLGeneratorContributor.CALL_GENERATOR(entities);
String title = "Stored procedures call";
if (entities.size() == 1 && !CommonUtils.isEmpty(procName)) {
title = procName + " call";
}
try {
openConsole(workbenchWindow, generator, navContext, title, false, currentSelection);
} catch (Exception e) {
DBWorkbench.getPlatformUI().showError("Open console", "Can open SQL editor", e);
}
return null;
}
use of org.jkiss.dbeaver.model.struct.rdb.DBSProcedure in project dbeaver by dbeaver.
the class SQLCompletionProposalBase method getExtraString.
public String getExtraString() {
try {
VoidProgressMonitor monitor = new VoidProgressMonitor();
if (object instanceof DBSObjectReference) {
if (DBSProcedure.class.isAssignableFrom(((DBSObjectReference) object).getObjectType().getTypeClass())) {
object = ((DBSObjectReference) object).resolveObject(monitor);
}
}
if (object instanceof DBSProcedure) {
// Ad parameter marks
boolean isExec = CommonUtils.toBoolean(params.get(PARAM_EXEC));
Collection<? extends DBSProcedureParameter> parameters = ((DBSProcedure) object).getParameters(monitor);
if (!CommonUtils.isEmpty(parameters)) {
StringBuilder params = new StringBuilder();
for (DBSProcedureParameter param : parameters) {
if (param.getParameterKind().isInput()) {
if (params.length() > 0)
params.append(", ");
if (isExec) {
params.append(":").append(param.getName());
} else {
params.append(param.getParameterType().getFullTypeName());
}
}
}
return "(" + params.toString() + ")";
} else {
return "()";
}
}
return null;
} catch (DBException e) {
log.error("Error resolving procedure parameters", e);
return null;
}
}
use of org.jkiss.dbeaver.model.struct.rdb.DBSProcedure in project dbeaver by dbeaver.
the class RunProcedureConsoleHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchWindow workbenchWindow = HandlerUtil.getActiveWorkbenchWindow(event);
DBPDataSourceContainer ds = null;
String procName = null;
List<DBSObject> selectedObjects = NavigatorUtils.getSelectedObjects(HandlerUtil.getCurrentSelection(event));
List<DBSProcedure> entities = new ArrayList<>();
for (DBSObject object : selectedObjects) {
if (object instanceof DBSProcedure) {
DBSProcedure proc = (DBSProcedure) object;
procName = proc.getName();
entities.add(proc);
ds = object.getDataSource().getContainer();
}
}
DBRRunnableWithResult<String> generator = GenerateSQLContributor.CALL_GENERATOR(entities);
String title = "Stored procedures call";
if (entities.size() == 1 && !CommonUtils.isEmpty(procName)) {
title = procName + " call";
}
openConsole(workbenchWindow, generator, ds, title, false);
return null;
}
Aggregations