Example #1
0
  private Element createStoredProcedureElement(final Document dom, final Routine sp) {
    final Schema schema = sp.getSchema();

    final Element eStoredProcedure = dom.createElement("storedprocedure");

    final boolean isFunction = sp.getRoutineType() == RoutineType.function;
    eStoredProcedure.setAttribute("type", isFunction ? "function" : "procedure");
    eStoredProcedure.setAttribute("schema", schema.getName());
    eStoredProcedure.setAttribute("catalog", sp.getSchema().getCatalogName());
    // System.out.printf ("%s> [%s] [%s]%n", sp.getName (), sp.getDefinition (),
    // sp.getRoutineBodyType ());

    final String storedProcedureName = getPhysicalName(sp.getName());
    eStoredProcedure.setAttribute("name", getLogicalName(storedProcedureName));
    eStoredProcedure.setAttribute("physicalname", storedProcedureName);

    final List<? extends RoutineColumn<? extends Routine>> parameters = sp.getColumns();
    for (final RoutineColumn<? extends Routine> parameter : parameters) {
      if (shouldIncludeParameter(sp, parameter)) {
        final Element eParameter = createParameterElement(dom, parameter);
        eStoredProcedure.appendChild(eParameter);
      }
    }

    return eStoredProcedure;
  }
Example #2
0
  private boolean shouldIncludeParameter(
      final Routine sp, final RoutineColumn<? extends Routine> parameter) {
    boolean should = true;

    if (m_options.m_ignoreReturnParameterOnProcedure) {
      final boolean isFunction = sp.getRoutineType() == RoutineType.function;

      if (!isFunction) {
        final RoutineColumnType columnType = parameter.getColumnType();
        if (columnType instanceof ProcedureColumnType
            && (ProcedureColumnType) columnType == ProcedureColumnType.returnValue) {
          should = false;
        }
      }
    }

    return should;
  }