コード例 #1
0
  /**
   * Copied and modified from RoutineUtil
   *
   * @param proc
   * @param values
   * @param pds
   * @param quoted_id
   * @return
   */
  private String constructCALLSPString(
      ProcIdentifier proc, List values, ParameterDescriptor[] pds, boolean quoted_id) {
    StringBuffer buffer = new StringBuffer(20);
    // Derby doesn't support {?=
    // buffer.append("?=");
    int type = proc == null ? ProcIdentifier.TYPE_SP : proc.getType();
    SQLDevToolsConfiguration config =
        SQLToolsFacade.getConfigurationByProfileName(proc.getDatabaseIdentifier().getProfileName());
    buffer.append(config.getExecutionService().getCallableStatementPrefix(proc.getType()));
    String procName = null;

    if (proc != null) {
      buffer.append(proc.getCallableString(quoted_id));
      procName = proc.getProcName();
    }
    if (pds != null && pds.length > 0) {
      if (type == ProcIdentifier.TYPE_UDF || type == ProcIdentifier.TYPE_SP) {
        buffer.append("("); // $NON-NLS-1$
      }
      int j = 0;
      for (int i = 0; i < pds.length; i++) {
        String name = pds[i].getName();

        if (name.equals(procName)) {
          continue;
        }
        if (j != 0) {
          buffer.append(",?"); // $NON-NLS-1$
        } else {
          buffer.append("?");
        }
        j++;
      }
      if (type == ProcIdentifier.TYPE_UDF || type == ProcIdentifier.TYPE_SP) {
        buffer.append(")"); // $NON-NLS-1$
      }
    } else {
      buffer.append("()");
    }
    // buffer.append("}");
    return buffer.toString();
  }
コード例 #2
0
 /**
  * Copied and modified from LaunchHelper
  *
  * @param configuration
  * @return
  * @throws CoreException
  */
 private String constructFinalCallSQLString(ILaunchConfiguration configuration)
     throws CoreException, SQLException, NoSuchProfileException {
   if (LaunchHelper.isAdHocSQL(configuration))
     return LaunchHelper.readLaunchSQLStatement(configuration);
   ProcIdentifier proc = LaunchHelper.readProcIdentifier(configuration);
   if (proc == null) return "";
   boolean quoted_id = LaunchHelper.readQuotedIDConfig(configuration, proc);
   switch (proc.getType()) {
     case ProcIdentifier.TYPE_SP:
     case ProcIdentifier.TYPE_UDF:
       return constructCALLSPString(
           proc,
           LaunchHelper.readParameterList(configuration),
           LaunchHelper.getAllParameterDescriptors(proc),
           quoted_id);
     case ProcIdentifier.TYPE_EVENT:
       // not supported
     default:
       return "";
   }
 }