Search in sources :

Example 1 with DBSProcedureParameter

use of org.jkiss.dbeaver.model.struct.rdb.DBSProcedureParameter in project dbeaver by serge-rider.

the class JDBCCallableStatementImpl method getResultSet.

@Nullable
@Override
public JDBCResultSet getResultSet() throws SQLException {
    JDBCResultSet resultSet = makeResultSet(getOriginal().getResultSet());
    if (resultSet == null && procedure != null) {
        JDBCResultSetCallable procResults = new JDBCResultSetCallable(getConnection(), this);
        try {
            Collection<? extends DBSProcedureParameter> params = procedure.getParameters(getConnection().getProgressMonitor());
            if (!CommonUtils.isEmpty(params)) {
                for (DBSProcedureParameter param : params) {
                    if (param.getParameterKind() == DBSProcedureParameterKind.OUT || param.getParameterKind() == DBSProcedureParameterKind.INOUT) {
                        procResults.addColumn(param.getName(), param.getParameterType());
                    }
                }
            }
        } catch (DBException e) {
            log.warn("Error extracting callable results", e);
        }
        procResults.addRow();
        return procResults;
    }
    return resultSet;
}
Also used : DBException(org.jkiss.dbeaver.DBException) DBSProcedureParameter(org.jkiss.dbeaver.model.struct.rdb.DBSProcedureParameter) JDBCResultSet(org.jkiss.dbeaver.model.exec.jdbc.JDBCResultSet) Nullable(org.jkiss.code.Nullable)

Example 2 with DBSProcedureParameter

use of org.jkiss.dbeaver.model.struct.rdb.DBSProcedureParameter in project dbeaver by serge-rider.

the class JDBCCallableStatementImpl method bindProcedureFromMeta.

void bindProcedureFromMeta() throws DBException {
    if (procedure == null) {
        return;
    }
    try {
        Collection<? extends DBSProcedureParameter> params = procedure.getParameters(getConnection().getProgressMonitor());
        if (!CommonUtils.isEmpty(params)) {
            int index = 0;
            for (DBSProcedureParameter param : params) {
                if (param.getParameterKind() == DBSProcedureParameterKind.OUT || param.getParameterKind() == DBSProcedureParameterKind.INOUT) {
                    index++;
                    registerOutParameter(index, param.getParameterType().getTypeID());
                }
            }
        }
    } catch (SQLException e) {
        throw new DBException("Error binding callable statement parameters", e);
    }
}
Also used : DBException(org.jkiss.dbeaver.DBException) DBSProcedureParameter(org.jkiss.dbeaver.model.struct.rdb.DBSProcedureParameter)

Aggregations

DBException (org.jkiss.dbeaver.DBException)2 DBSProcedureParameter (org.jkiss.dbeaver.model.struct.rdb.DBSProcedureParameter)2 Nullable (org.jkiss.code.Nullable)1 JDBCResultSet (org.jkiss.dbeaver.model.exec.jdbc.JDBCResultSet)1