Package java.sql

Examples of java.sql.CallableStatement


   * Delete all messages from this folder and clear MBOX file
   * @throws MessagingException
   */
  public void wipe() throws MessagingException {
    Statement oStmt = null;
    CallableStatement oCall = null;
    PreparedStatement oUpdt = null;
    PreparedStatement oPart = null;
    PreparedStatement oAddr = null;
    ResultSet oRSet;

    if (DebugFile.trace) {
      DebugFile.writeln("Begin DBFolder.wipe()");
      DebugFile.incIdent();
    }

    // *************************************************************************
    // If Folder is not opened is read-write mode then raise an exception
    if (0==(iOpenMode&READ_WRITE)) {
      if (DebugFile.trace) DebugFile.decIdent();
      throw new javax.mail.FolderClosedException(this, "Folder is not open is READ_WRITE mode");
    }

    if ((0==(iOpenMode&MODE_MBOX)) && (0==(iOpenMode&MODE_BLOB))) {
      if (DebugFile.trace) DebugFile.decIdent();
      throw new javax.mail.FolderClosedException(this, "Folder is not open in MBOX nor BLOB mode");
    }

    // *************************************************
    // Get the list of all messages stored at this folder

    MboxFile oMBox = null;
    DBSubset oDeleted = new DBSubset(DB.k_mime_msgs, DB.gu_mimemsg+","+DB.pg_message, DB.gu_category+"='"+oCatg.getString(DB.gu_category)+"'", 100);
    JDCConnection oConn = null;

    try {
    oConn = getConnection();
      int iDeleted = oDeleted.load(oConn);
      if (DebugFile.trace) DebugFile.writeln("there are "+String.valueOf(iDeleted)+" messages to be deleted");

      // ****************************************
      // Erase files referenced by draft messages   
      oStmt = oConn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
      if (DebugFile.trace) DebugFile.writeln("Statement.executeQuery(SELECT p." + DB.file_name + " FROM " + DB.k_mime_parts + " p," + DB.k_mime_msgs + " m WHERE p." + DB.gu_mimemsg + "=m."+ DB.gu_mimemsg + " AND m." + DB.id_disposition + "='reference' AND m." + DB.bo_deleted + "=1 AND m." + DB.gu_category +"='"+oCatg.getString(DB.gu_category)+"')");
      oRSet = oStmt.executeQuery("SELECT p." + DB.file_name + " FROM " + DB.k_mime_parts + " p," + DB.k_mime_msgs + " m WHERE p." + DB.gu_mimemsg + "=m."+ DB.gu_mimemsg + " AND m." + DB.id_disposition + "='reference' AND m." + DB.bo_deleted + "=1 AND m." + DB.gu_category +"='"+oCatg.getString(DB.gu_category)+"'");

      while (oRSet.next()) {
        String sFileName = oRSet.getString(1);
        if (!oRSet.wasNull()) {
          try {
            File oRef = new File(sFileName);
            if (oRef.exists()) oRef.delete();
          }
          catch (SecurityException se) {
            if (DebugFile.trace) DebugFile.writeln("SecurityException " + sFileName + " " + se.getMessage());
          }
        }
      } // wend

      oRSet.close();
      oRSet = null;
      oStmt.close();
      oStmt = null;

      // *************************
      // Set Category size to zero

      oStmt = oConn.createStatement();
      if (DebugFile.trace) DebugFile.writeln("Statement.executeUpdate(UPDATE "+DB.k_categories+" SET "+DB.len_size+"=0 WHERE "+DB.gu_category+"='"+getCategory().getString(DB.gu_category)+"')");
      oStmt.executeUpdate("UPDATE "+DB.k_categories+" SET "+DB.len_size+"=0 WHERE "+DB.gu_category+"='"+getCategory().getString(DB.gu_category)+"'");
      oStmt.close();
      oStmt=null;

      // *********************************************
      // Actually delete messages from database tables

      if (oConn.getDataBaseProduct()==JDCConnection.DBMS_POSTGRESQL) {
        oStmt = oConn.createStatement();
        for (int d=0; d<iDeleted; d++)
          oStmt.executeQuery("SELECT k_sp_del_mime_msg('" + oDeleted.getString(0,d) + "')");
        oStmt.close();
        oStmt=null;
      }
      else {
        oCall = oConn.prepareCall("{ call k_sp_del_mime_msg(?) }");

        for (int d=0; d<iDeleted; d++) {
          oCall.setString(1, oDeleted.getString(0,d));
          oCall.execute();
        } // next
        oCall.close();
        oCall=null;
      }

      // *************************************
      // Truncate MBOX file

      File oFile = getFile();
      if (oFile.exists()) {
        if (DebugFile.trace) DebugFile.writeln("File.delete("+getFilePath()+")");
        oFile.delete();
      }

      if (DebugFile.trace) DebugFile.writeln("Connection.commit()");

      oConn.commit();
    } catch (Exception sqle) {
      try { if (oMBox!=null) oMBox.close(); } catch (Exception e) {}
      try { if (oStmt!=null) oStmt.close(); } catch (Exception e) {}
      try { if (oCall!=null) oCall.close(); } catch (Exception e) {}
      try { if (oConn!=null) oConn.rollback(); } catch (Exception e) {}
      throw new MessagingException (sqle.getMessage(), sqle);
    }

    if (DebugFile.trace) {
View Full Code Here


   * @param sDomainNm Domain name (nm_domain from k_domains table)
   * @return Domain Identifier
   * @throws SQLException
   */
  public static int getIdFromName(JDCConnection oConn, String sDomainNm) throws SQLException {
    CallableStatement oCall;
    PreparedStatement oStmt;
    ResultSet oRSet;
    int iDomainId;

    switch (oConn.getDataBaseProduct()) {

      case JDCConnection.DBMS_MYSQL:
      case JDCConnection.DBMS_MSSQL:
      case JDCConnection.DBMS_ORACLE:
        oCall = oConn.prepareCall("{call k_get_domain_id (?,?)}");
        oCall.setString(1, sDomainNm);
        oCall.registerOutParameter(2, java.sql.Types.INTEGER);
        oCall.execute();
        iDomainId = oCall.getInt(2);
        oCall.close();
        oCall = null;
        break;

      default:
        oStmt = oConn.prepareStatement("SELECT " + DB.id_domain + " FROM " + DB.k_domains + " WHERE " + DB.nm_domain + "=?", ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
View Full Code Here

        oStmt.close();
        bRetVal = true;
        break;
      default:
        if (DebugFile.trace) DebugFile.writeln("Connection.prepareCall({ call k_sp_del_group ('" + sGroupGUID + "') })");
        CallableStatement oCall = oConn.prepareCall("{ call k_sp_del_group ('" + sGroupGUID + "') }");
        bRetVal = oCall.execute();
        oCall.close();
    }

    if (DebugFile.trace) {
      DebugFile.decIdent();
      DebugFile.writeln("End ACLGroup.delete() : " + String.valueOf(bRetVal));
View Full Code Here

  */

  public static void delete (JDCConnection oConn, String sFolderId, String sMimeMsgId)
      throws SQLException,IOException {
      Statement oStmt;
      CallableStatement oCall;

      if (DebugFile.trace) {
        DebugFile.writeln("Begin DBMimeMessage.delete([Connection], "+sMimeMsgId+")");
        DebugFile.incIdent();
      }

      oStmt = oConn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
      ResultSet oRSet = oStmt.executeQuery("SELECT " + DB.file_name + " FROM " + DB.k_mime_parts + " WHERE " + DB.gu_mimemsg + "='"+sMimeMsgId+"' AND " + DB.id_disposition + "='reference'");

      while (oRSet.next()) {
        String sFileName = oRSet.getString(1);
        if (!oRSet.wasNull()) {
          try {
            File oRef = new File(sFileName);
            oRef.delete();
          }
          catch (SecurityException se) {
            if (DebugFile.trace) DebugFile.writeln("SecurityException " + sFileName + " " + se.getMessage());
          }
        }
      } // wend

      oRSet.close();
      oRSet = null;
      oStmt.close();
      oStmt = null;

      if (oConn.getDataBaseProduct()==JDCConnection.DBMS_POSTGRESQL) {
        oStmt = oConn.createStatement();
        oStmt.executeQuery("SELECT k_sp_del_mime_msg('" + sMimeMsgId + "')");
        oStmt.close();
      }
      else {
        oCall = oConn.prepareCall("{ call k_sp_del_mime_msg(?) }");
        oCall.setString(1, sMimeMsgId);
        oCall.execute();
        oCall.close();
      }

      if (DebugFile.trace) {
        DebugFile.decIdent();
        DebugFile.writeln("End DBMimeMessage.delete()");
View Full Code Here

          oRSet = null;
          oStmt.close();
          oStmt = null;
          break;
        default:
          CallableStatement oCall = oConn.prepareCall("{ call k_sp_get_mime_msg(?,?) }");
          oCall.setString(1, sMsgId);
          oCall.registerOutParameter(2, Types.CHAR);
          oCall.execute();
          sMsgGuid = oCall.getString(2);
          if (sMsgGuid!=null) sMsgGuid = sMsgGuid.trim();
          oCall.close();
          oCall = null;
      }
      return sMsgGuid;
    }
View Full Code Here

    }
    else {
      if (DebugFile.trace)
        DebugFile.writeln("Connection.prepareCall({ call k_sp_del_contact ('" + sContactGUID + "') }");

      CallableStatement oCall = oConn.prepareCall("{ call k_sp_del_contact ('" + sContactGUID + "') }");
      bRetVal = oCall.execute();
      oCall.close();
    }

    if (DebugFile.trace) {
      DebugFile.decIdent();
      DebugFile.writeln("End Contact.delete() : " + String.valueOf(bRetVal));
View Full Code Here

   * @param oConn Database Connection
   * @param sWrkAreaGUID GUID of WorkArea to be deleted.
   * @throws SQLException
   */
  public static boolean delete(JDCConnection oConn, String sWrkAreaGUID) throws SQLException {
    CallableStatement oCall;
    Statement oStmt;
    PreparedStatement oPtmt;
    ResultSet oRSet;
    DBSubset oItems;
    String sSQL;
    int iItems;

    if (DebugFile.trace) {
      DebugFile.writeln("Begin WorkArea.delete([Connection], " + sWrkAreaGUID + ")");
      DebugFile.incIdent();
    }

  if (null!=oParams) oParams.clear();

    // -----------------------------------------------------------------------------------
    // Verificar que la WorkArea realmente existe antes de empezar a borrar y tambien
    // evitar que una inyección maliciosa de SQL en el parámetro sWrkAreaGUID pudiera
    // borrar más registros de los debidos

    oPtmt = oConn.prepareStatement("SELECT "+DB.gu_workarea+" FROM "+DB.k_workareas+" WHERE "+DB.gu_workarea+"=?",
                                   ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
    oPtmt.setString(1, sWrkAreaGUID);
    oRSet = oPtmt.executeQuery();
    boolean bExists = oRSet.next();
    oRSet.close();
    oPtmt.close();

    if (!bExists) {
      if (DebugFile.trace) {
        DebugFile.writeln("workarea " + sWrkAreaGUID + " not found");
        DebugFile.decIdent();
        DebugFile.writeln("End WorkArea.delete() : false");
      }
      return false;
    }

    // -----------------------------------------------------------------------------------
    // Nuevo para v6.0
    // Borrar las entradas de feeds RSS

    if (DBBind.exists(oConn, DB.k_syndentries, "U")) {
      oStmt = oConn.createStatement();
      if (DebugFile.trace) DebugFile.writeln("Statement.executeUpdate(DELETE FROM " + DB.k_syndentries + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "')");

      oStmt.executeUpdate("DELETE FROM " + DB.k_syndentries + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "'");
   
      oStmt.close();
    }

    // -----------------------------------------------------------------------------------
    // Nuevo para v5.0
    // Borrar las actividades

    if (DBBind.exists(oConn, DB.k_activities, "U")) {
      oStmt = oConn.createStatement();
      if (DebugFile.trace) DebugFile.writeln("Statement.executeUpdate(DELETE FROM " + DB.k_x_activity_audience + " WHERE " + DB.gu_activity + " IN (SELECT " + DB.gu_activity +" FROM " + DB.k_activities+ " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "'))");

      oStmt.executeUpdate("DELETE FROM " + DB.k_x_activity_audience + " WHERE " + DB.gu_activity + " IN (SELECT " + DB.gu_activity +" FROM " + DB.k_activities+ " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "')");
   
      if (DebugFile.trace) DebugFile.writeln("Statement.executeUpdate(DELETE FROM " + DB.k_activities + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "')");

      oStmt.executeUpdate("DELETE FROM " + DB.k_activities + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "'");
   
      oStmt.close();
    }

    // -----------------------------------------------------------------------------------
    // Nuevo para v5.0
    // Borrar los SMS

    if (DBBind.exists(oConn, DB.k_sms_audit, "U")) {
      oStmt = oConn.createStatement();
      if (DebugFile.trace) DebugFile.writeln("Statement.executeUpdate(DELETE FROM " + DB.k_sms_audit + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "')");

      oStmt.executeUpdate("DELETE FROM " + DB.k_sms_audit + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "'");
   
      oStmt.close();
    }

    // -----------------------------------------------------------------------------------
    // Borrar los e-mails

  if (DBBind.exists(oConn, DB.k_adhoc_mailings, "U")) {
      oStmt = oConn.createStatement();
      if (DebugFile.trace) DebugFile.writeln("Statement.executeUpdate(DELETE FROM " + DB.k_adhoc_mailings_lookup + " WHERE " + DB.gu_owner + "='" + sWrkAreaGUID + "')");
      oStmt.executeUpdate("DELETE FROM " + DB.k_adhoc_mailings_lookup + " WHERE  " + DB.gu_owner + "='" + sWrkAreaGUID + "'");
      oStmt.close();
      DBSubset oMailings = new DBSubset(DB.k_adhoc_mailings, DB.gu_mailing, DB.gu_workarea+"=?", 1000);
      int iMailings = oMailings.load(oConn, new Object[]{sWrkAreaGUID});
      AdHocMailing oAdhc = new AdHocMailing();
      for (int m=0; m<iMailings; m++) {
        oAdhc.load(oConn, new Object[]{oMailings.getString(DB.gu_mailing,m)});
        oAdhc.delete(oConn);
      } // next
  } // fi

    if (DBBind.exists(oConn, DB.k_mime_msgs, "U")) {
      oStmt = oConn.createStatement();

      if (DebugFile.trace) DebugFile.writeln("Statement.executeUpdate(DELETE FROM " + DB.k_x_cat_objs + " WHERE " + DB.gu_object + " IN (SELECT " + DB.gu_mimemsg + " FROM k_mime_msgs WHERE gu_workarea='" + sWrkAreaGUID + "') AND " + DB.id_class + "=822)");

      oStmt.executeUpdate("DELETE FROM " + DB.k_x_cat_objs + " WHERE " + DB.gu_object + " IN (SELECT " + DB.gu_mimemsg + " FROM k_mime_msgs WHERE gu_workarea='" + sWrkAreaGUID + "') AND " + DB.id_class + "=822");

      if (DebugFile.trace) DebugFile.writeln("Statement.executeUpdate(DELETE FROM " + DB.k_inet_addrs + " WHERE " + DB.gu_mimemsg + " IN (SELECT " + DB.gu_mimemsg + " FROM " + DB.k_mime_msgs + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "'))");

      oStmt.executeUpdate("DELETE FROM " + DB.k_inet_addrs + " WHERE " + DB.gu_mimemsg + " IN (SELECT " + DB.gu_mimemsg + " FROM " + DB.k_mime_msgs + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "')");

      if (DebugFile.trace) DebugFile.writeln("Statement.executeUpdate(DELETE FROM " + DB.k_mime_parts + " WHERE " + DB.gu_mimemsg + " IN (SELECT " + DB.gu_mimemsg + " FROM " + DB.k_mime_msgs + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "'))");

      oStmt.executeUpdate("DELETE FROM " + DB.k_mime_parts + " WHERE " + DB.gu_mimemsg + " IN (SELECT " + DB.gu_mimemsg + " FROM " + DB.k_mime_msgs + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "')");

      if (DebugFile.trace) DebugFile.writeln("Statement.executeUpdate(DELETE FROM " + DB.k_mime_msgs + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "')");

      oStmt.executeUpdate("DELETE FROM " + DB.k_mime_msgs + " WHERE  " + DB.gu_workarea + "='" + sWrkAreaGUID + "'");

      oStmt.close();
    }

    // -----------------------------------------------------------------------------------
    // Borrar las preferencias de usuario para portlets

    if (DBBind.exists(oConn, DB.k_x_portlet_user, "U")) {
      oStmt = oConn.createStatement();

      if (DebugFile.trace) DebugFile.writeln("Statement.executeUpdate(DELETE FROM " + DB.k_x_portlet_user + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "')");

      oStmt.executeUpdate("DELETE FROM " + DB.k_x_portlet_user + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "'");

      oStmt.close();
    }

    // -----------------------------------------------------------------------------------
    // Borrar las consultas

    if (DBBind.exists(oConn, DB.k_queries, "U")) {
      oItems = new DBSubset (DB.k_queries, DB.gu_query, DB.gu_workarea + "='" + sWrkAreaGUID + "'", 100);
      iItems = oItems.load(oConn);

      for (int p=0;p<iItems; p++)
        QueryByForm.delete(oConn, oItems.getString(0, p));
    }
    // -----------------------------------------------------------------------------------

    // Borrar los pagesets
    if (DBBind.exists(oConn, DB.k_pagesets, "U")) {
      oItems = new DBSubset (DB.k_pagesets, DB.gu_pageset, DB.gu_workarea + "='" + sWrkAreaGUID + "'", 100);
      iItems = oItems.load(oConn);
      for (int p=0;p<iItems; p++)
        PageSetDB.delete(oConn, oItems.getString(0,p));
    }

    // -----------------------------------------------------------------------------------

    // Borrar los microsites
    if (DBBind.exists(oConn, DB.k_microsites, "U")) {
      oItems = new DBSubset (DB.k_microsites, DB.gu_microsite, DB.gu_workarea + "='" + sWrkAreaGUID + "'", 100);
      iItems = oItems.load(oConn);
      for (int p=0;p<iItems; p++)
        new MicrositeDB(oConn, oItems.getString(0,p)).delete(oConn);
    }

    // -----------------------------------------------------------------------------------
    // Nuevo para la v2.1
    // Borrar las imagenes

    if (DBBind.exists(oConn, DB.k_images, "U")) {
      oItems = new DBSubset (DB.k_images, DB.gu_image, DB.gu_workarea + "='" + sWrkAreaGUID + "'", 100);
      iItems = oItems.load(oConn);
      for (int p=0;p<iItems; p++)
        new Image(oConn, oItems.getString(0,p)).delete(oConn);
    }

    // -----------------------------------------------------------------------------------
    // Borrar las listas

    if (DBBind.exists(oConn, DB.k_global_black_list, "U")) {
      oStmt = oConn.createStatement();
      if (DebugFile.trace) DebugFile.writeln("Statement.executeUpdate(DELETE FROM " + DB.k_global_black_list + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "')");
      oStmt.executeUpdate("DELETE FROM " + DB.k_global_black_list + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "'");
      oStmt.close();
    }

    if (DBBind.exists(oConn, DB.k_lists, "U")) {
      oItems = new DBSubset (DB.k_lists, DB.gu_list, DB.gu_workarea + "='" + sWrkAreaGUID + "'", 100);
      iItems = oItems.load(oConn);
      for (int p=0;p<iItems; p++)
        DistributionList.delete(oConn, oItems.getString(0,p));
    }
    // -----------------------------------------------------------------------------------

    // Borrar actividades, compañeros y salas

    if (DBBind.exists(oConn, DB.k_meetings, "U")) {
      oItems = new DBSubset (DB.k_meetings, DB.gu_meeting, DB.gu_workarea + "='" + sWrkAreaGUID + "'", 100);
      iItems = oItems.load(oConn);
      for (int c=0;c<iItems; c++)
        Meeting.delete(oConn, oItems.getString(0,c));
    }

    if (DBBind.exists(oConn, DB.k_fellows, "U")) {
      oItems = new DBSubset (DB.k_fellows, DB.gu_fellow, DB.gu_workarea + "='" + sWrkAreaGUID + "'", 100);
      iItems = oItems.load(oConn);
      for (int c=0;c<iItems; c++)
        Fellow.delete(oConn, oItems.getString(0,c));
    }

    if (DBBind.exists(oConn, DB.k_lu_fellow_titles, "U")) {
      oStmt = oConn.createStatement();
      sSQL = "DELETE FROM " + DB.k_lu_fellow_titles + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "'";
      if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")");
      oStmt.execute(sSQL);
      oStmt.close();
    }

    if (DBBind.exists(oConn, DB.k_fellows_lookup, "U")) {
      oStmt = oConn.createStatement();
      try { if (oConn.getDataBaseProduct()!=JDCConnection.DBMS_POSTGRESQL) oStmt.setQueryTimeout(30); } catch (SQLException sqle) {}
      sSQL = "DELETE FROM " + DB.k_fellows_lookup + " WHERE " + DB.gu_owner + "='" + sWrkAreaGUID + "'";
      if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")");
      oStmt.execute(sSQL);
      oStmt.close();
    }

    if (DBBind.exists(oConn, DB.k_rooms, "U")) {
      oItems = new DBSubset (DB.k_rooms, DB.nm_room, DB.gu_workarea + "='" + sWrkAreaGUID + "'", 100);
      iItems = oItems.load(oConn);
      for (int c=0;c<iItems; c++)
        Room.delete(oConn, oItems.getString(0,c), sWrkAreaGUID);
    }

    if (DBBind.exists(oConn, DB.k_rooms_lookup, "U")) {
      oStmt = oConn.createStatement();
      try { if (oConn.getDataBaseProduct()!=JDCConnection.DBMS_POSTGRESQL) oStmt.setQueryTimeout(30); } catch (SQLException sqle) {}
      sSQL = "DELETE FROM " + DB.k_rooms_lookup + " WHERE " + DB.gu_owner + "='" + sWrkAreaGUID + "'";
      if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")");
      oStmt.execute(sSQL);
      oStmt.close();
    }

    // -----------------------------------------------------------------------------------
    // Borrar ToDo Lists

    if (DBBind.exists(oConn, DB.k_to_do, "U")) {
      oStmt = oConn.createStatement();
      try { if (oConn.getDataBaseProduct()!=JDCConnection.DBMS_POSTGRESQL) oStmt.setQueryTimeout(30); } catch (SQLException sqle) {}
      sSQL = "DELETE FROM " + DB.k_to_do + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "'";
      if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")");
      oStmt.execute(sSQL);
      oStmt.close();
    }

    if (DBBind.exists(oConn, DB.k_to_do_lookup, "U")) {
      oStmt = oConn.createStatement();
      try { if (oConn.getDataBaseProduct()!=JDCConnection.DBMS_POSTGRESQL) oStmt.setQueryTimeout(30); } catch (SQLException sqle) {}
      sSQL = "DELETE FROM " + DB.k_to_do_lookup + " WHERE " + DB.gu_owner + "='" + sWrkAreaGUID + "'";
      if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")");
      oStmt.execute(sSQL);
      oStmt.close();
    }

    // -----------------------------------------------------------------------------------
    // Borrar llamadas de teléfono

    if (DBBind.exists(oConn, DB.k_phone_calls, "U")) {
      oStmt = oConn.createStatement();
      try { if (oConn.getDataBaseProduct()!=JDCConnection.DBMS_POSTGRESQL) oStmt.setQueryTimeout(30); } catch (SQLException sqle) {}
      sSQL = "DELETE FROM " + DB.k_phone_calls + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "'";
      if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")");
      oStmt.execute(sSQL);
      oStmt.close();
    }

    // -----------------------------------------------------------------------------------
    // Borrar el datawarehouse de direcciones

    if (DBBind.exists(oConn, DB.k_member_address, "U")) {

      oStmt = oConn.createStatement();
      try { if (oConn.getDataBaseProduct()!=JDCConnection.DBMS_POSTGRESQL) oStmt.setQueryTimeout(30); } catch (SQLException sqle) {}

      sSQL = "DELETE FROM " + DB.k_member_address + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "'";
      if (DebugFile.trace) DebugFile.writeln("Statement.executeUpdate(" + sSQL + ")");
      oStmt.executeUpdate(sSQL);

      oStmt.close();
    }

    // -----------------------------------------------------------------------------------

    // Borrar los Vendedores
    if (DBBind.exists(oConn, DB.k_sales_men, "U")) {
      oItems = new DBSubset (DB.k_sales_men, DB.gu_sales_man, DB.gu_workarea + "='" + sWrkAreaGUID + "'", 100);
      iItems = oItems.load(oConn);

      if (oConn.getDataBaseProduct()==JDCConnection.DBMS_POSTGRESQL) {
        if (DebugFile.trace) DebugFile.writeln("Connection.prepareStatement(SELECT k_sp_del_sales_man (?))");
         oPtmt = oConn.prepareStatement("SELECT k_sp_del_sales_man (?)");
         for (int c=0;c<iItems; c++) {
           oPtmt.setString(1, oItems.getString(0,c));
           oPtmt.executeQuery();
         } // next
         oPtmt.close();
      }
      else {
        if (DebugFile.trace) DebugFile.writeln("Connection.prepareCall({ call k_sp_del_sales_man (?) })");
         oCall = oConn.prepareCall("{call k_sp_del_sales_man (?)}");
         for (int c=0;c<iItems; c++) {
           oCall.setString(1, oItems.getString(0,c));
           oCall.execute();
         } // next
         oCall.close();
      }
    } // fi (DBMS_POSTGRESQL)

    if (DBBind.exists(oConn, DB.k_sales_men_lookup, "U")) {
      oStmt = oConn.createStatement();
      try { if (oConn.getDataBaseProduct()!=JDCConnection.DBMS_POSTGRESQL) oStmt.setQueryTimeout(30); } catch (SQLException sqle) {}
      sSQL = "DELETE FROM " + DB.k_sales_men_lookup + " WHERE " + DB.gu_owner + "='" + sWrkAreaGUID + "'";
      if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")");
      oStmt.execute(sSQL);
      oStmt.close();
    }

    // -----------------------------------------------------------------------------------
    // Nuevo para la v5.5, borrar los lotes de carga
    if (DBBind.exists(oConn, DB.k_bulkloads, "U")) {
      oStmt = oConn.createStatement();
      try { if (oConn.getDataBaseProduct()!=JDCConnection.DBMS_POSTGRESQL) oStmt.setQueryTimeout(30); } catch (SQLException sqle) {}
      sSQL = "DELETE FROM " + DB.k_bulkloads + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "'";
      if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")");
      oStmt.execute(sSQL);
      oStmt.close();
    }   
     
    // -----------------------------------------------------------------------------------
    // Nuevo para la v4.0, borrar los proveedores
    if (DBBind.exists(oConn, DB.k_suppliers, "U")) {
      oItems = new DBSubset (DB.k_suppliers, DB.gu_supplier, DB.gu_workarea + "='" + sWrkAreaGUID + "'", 100);
      iItems = oItems.load(oConn);
      for (int c=0;c<iItems; c++)
        Supplier.delete(oConn, oItems.getString(0,c));
    }


    // -----------------------------------------------------------------------------------
    // Borrar las compañías, cada compañía borrará en cascada sus individuos asociados

    if (DBBind.exists(oConn, DB.k_companies, "U")) {
      oItems = new DBSubset (DB.k_companies, DB.gu_company, DB.gu_workarea + "='" + sWrkAreaGUID + "'", 100);
      iItems = oItems.load(oConn);
      for (int c=0;c<iItems; c++)
        Company.delete(oConn, oItems.getString(0,c));
    }

    // Borrar los contactos, puede haber contactos individuales no asociados a ninguna compañia
    if (DBBind.exists(oConn, DB.k_contacts, "U")) {
      oItems = new DBSubset (DB.k_contacts, DB.gu_contact, DB.gu_workarea + "='" + sWrkAreaGUID + "'", 100);
      iItems = oItems.load(oConn);
      for (int c=0;c<iItems; c++)
        Contact.delete(oConn, oItems.getString(0,c));
    }

    if (DBBind.exists(oConn, DB.k_companies_lookup, "U")) {
      oStmt = oConn.createStatement();
      try { if (oConn.getDataBaseProduct()!=JDCConnection.DBMS_POSTGRESQL) oStmt.setQueryTimeout(30); } catch (SQLException sqle) {}
      sSQL = "DELETE FROM " + DB.k_companies_lookup + " WHERE " + DB.gu_owner + "='" + sWrkAreaGUID + "'";
      if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")");
      oStmt.execute(sSQL);
      oStmt.close();
    }

    if (DBBind.exists(oConn, DB.k_contacts_lookup, "U")) {
      oStmt = oConn.createStatement();
      try { if (oConn.getDataBaseProduct()!=JDCConnection.DBMS_POSTGRESQL) oStmt.setQueryTimeout(30); } catch (SQLException sqle) {}
      sSQL = "DELETE FROM " + DB.k_contacts_lookup + " WHERE " + DB.gu_owner + "='" + sWrkAreaGUID + "'";
      if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")");
      oStmt.execute(sSQL);
      oStmt.close();
    }

    if (DBBind.exists(oConn, DB.k_oportunities_lookup, "U")) {
      oStmt = oConn.createStatement();
      try { if (oConn.getDataBaseProduct()!=JDCConnection.DBMS_POSTGRESQL) oStmt.setQueryTimeout(30); } catch (SQLException sqle) {}
      sSQL = "DELETE FROM " + DB.k_oportunities_lookup + " WHERE " + DB.gu_owner + "='" + sWrkAreaGUID + "'";
      if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")");
      oStmt.execute(sSQL);
      oStmt.close();
    }

    if (DBBind.exists(oConn, DB.k_welcome_packs_lookup, "U")) {
      oStmt = oConn.createStatement();
      try { if (oConn.getDataBaseProduct()!=JDCConnection.DBMS_POSTGRESQL) oStmt.setQueryTimeout(30); } catch (SQLException sqle) {}
      sSQL = "DELETE FROM " + DB.k_welcome_packs_lookup + " WHERE " + DB.gu_owner + "='" + sWrkAreaGUID + "'";
      if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")");
      oStmt.execute(sSQL);
      oStmt.close();
    }

    // -----------------------------------------------------------------------------------

    // Borrar los proyectos, cada proyecto borrará en cascada sus incidencias y tareas
    if (DBBind.exists(oConn, DB.k_projects, "U")) {
      oItems = new DBSubset (DB.k_projects, DB.gu_project, DB.gu_owner + "='" + sWrkAreaGUID + "'", 100);
      iItems = oItems.load(oConn);
      for (int p=0;p<iItems; p++)
        Project.delete(oConn, oItems.getString(0,p));
    }

    if (DBBind.exists(oConn, DB.k_projects_lookup, "U")) {
      oStmt = oConn.createStatement();
      try { if (oConn.getDataBaseProduct()!=JDCConnection.DBMS_POSTGRESQL) oStmt.setQueryTimeout(30); } catch (SQLException sqle) {}
      sSQL = "DELETE FROM " + DB.k_projects_lookup + " WHERE " + DB.gu_owner + "='" + sWrkAreaGUID + "'";
      if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")");
      oStmt.execute(sSQL);
      oStmt.close();
    }

    if (DBBind.exists(oConn, DB.k_duties_lookup, "U")) {
      oStmt = oConn.createStatement();
      try { if (oConn.getDataBaseProduct()!=JDCConnection.DBMS_POSTGRESQL) oStmt.setQueryTimeout(30); } catch (SQLException sqle) {}
      sSQL = "DELETE FROM " + DB.k_duties_lookup + " WHERE " + DB.gu_owner + "='" + sWrkAreaGUID + "'";
      if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")");
      oStmt.execute(sSQL);
      oStmt.close();
    }

    if (DBBind.exists(oConn, DB.k_bugs_lookup, "U")) {
      oStmt = oConn.createStatement();
      try { if (oConn.getDataBaseProduct()!=JDCConnection.DBMS_POSTGRESQL) oStmt.setQueryTimeout(30); } catch (SQLException sqle) {}
      sSQL = "DELETE FROM " + DB.k_bugs_lookup + " WHERE " + DB.gu_owner + "='" + sWrkAreaGUID + "'";
      if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")");
      oStmt.execute(sSQL);
      oStmt.close();
    }

    // -----------------------------------------------------------------------------------
    // Borrar las tiendas, cada tienda borrará en cascada sus categorías y productos

    if (DBBind.exists(oConn, DB.k_invoices, "U")) {
      oStmt = oConn.createStatement();
      try { if (oConn.getDataBaseProduct()!=JDCConnection.DBMS_POSTGRESQL) oStmt.setQueryTimeout(30); } catch (SQLException sqle) {}

      sSQL = "DELETE FROM " + DB.k_x_orders_invoices + " WHERE " + DB.gu_order + " IN (SELECT "+DB.gu_order+" FROM "+DB.k_orders+" WHERE "+DB.gu_workarea+"='"+sWrkAreaGUID + "')";
      if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")");
      oStmt.execute(sSQL);

      sSQL = "DELETE FROM " + DB.k_invoice_lines + " WHERE " + DB.gu_invoice + " IN (SELECT "+DB.gu_invoice+" FROM "+DB.k_invoices+" WHERE "+DB.gu_workarea+"='"+sWrkAreaGUID + "') OR "+DB.gu_invoice+" IN (SELECT "+DB.gu_invoice+" FROM "+DB.k_returned_invoices+" WHERE "+DB.gu_workarea+"='"+sWrkAreaGUID + "')";
      if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")");
      oStmt.execute(sSQL);

      sSQL = "DELETE FROM " + DB.k_invoice_schedules + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "'";
      if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")");
      oStmt.execute(sSQL);

      sSQL = "DELETE FROM " + DB.k_invoices + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "'";
      if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")");
      oStmt.execute(sSQL);

      sSQL = "DELETE FROM " + DB.k_invoices_lookup + " WHERE " + DB.gu_owner + "='" + sWrkAreaGUID + "'";
      if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")");
      oStmt.execute(sSQL);

      oStmt.close();
    }

    if (DBBind.exists(oConn, DB.k_invoices_next, "U")) {
      oStmt = oConn.createStatement();
      try { if (oConn.getDataBaseProduct()!=JDCConnection.DBMS_POSTGRESQL) oStmt.setQueryTimeout(30); } catch (SQLException sqle) {}
      sSQL = "DELETE FROM " + DB.k_invoices_next + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "'";
      if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")");
      oStmt.execute(sSQL);
      oStmt.close();
    }

    if (DBBind.exists(oConn, DB.k_despatch_advices, "U")) {
      oStmt = oConn.createStatement();
      try { if (oConn.getDataBaseProduct()!=JDCConnection.DBMS_POSTGRESQL) oStmt.setQueryTimeout(30); } catch (SQLException sqle) {}

      sSQL = "DELETE FROM " + DB.k_x_orders_despatch + " WHERE " + DB.gu_despatch + " IN (SELECT "+DB.gu_despatch+" FROM "+DB.k_despatch_advices+" WHERE "+DB.gu_workarea+"='"+sWrkAreaGUID + "')";
      if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")");
      oStmt.execute(sSQL);

      sSQL = "DELETE FROM " + DB.k_despatch_lines + " WHERE " + DB.gu_despatch + " IN (SELECT "+DB.gu_despatch+" FROM "+DB.k_despatch_advices+" WHERE "+DB.gu_workarea+"='"+sWrkAreaGUID + "')";
      if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")");
      oStmt.execute(sSQL);

      sSQL = "DELETE FROM " + DB.k_despatch_advices + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "'";
      if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")");
      oStmt.execute(sSQL);

      sSQL = "DELETE FROM " + DB.k_despatch_advices_lookup + " WHERE " + DB.gu_owner + "='" + sWrkAreaGUID + "'";
      if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")");
      oStmt.execute(sSQL);
      oStmt.close();
    }

    if (DBBind.exists(oConn, DB.k_despatch_next, "U")) {
      oStmt = oConn.createStatement();
      try { if (oConn.getDataBaseProduct()!=JDCConnection.DBMS_POSTGRESQL) oStmt.setQueryTimeout(30); } catch (SQLException sqle) {}
      sSQL = "DELETE FROM " + DB.k_despatch_next + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "'";
      if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")");
      oStmt.execute(sSQL);
      oStmt.close();
    }

    if (DBBind.exists(oConn, DB.k_orders, "U")) {
      oStmt = oConn.createStatement();
      try { if (oConn.getDataBaseProduct()!=JDCConnection.DBMS_POSTGRESQL) oStmt.setQueryTimeout(30); } catch (SQLException sqle) {}

      sSQL = "DELETE FROM " + DB.k_order_lines + " WHERE " + DB.gu_order + " IN (SELECT "+DB.gu_order+" FROM "+DB.k_orders+" WHERE "+DB.gu_workarea+"='"+sWrkAreaGUID + "')";
      if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")");
      oStmt.execute(sSQL);

      sSQL = "DELETE FROM " + DB.k_orders + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "'";
      if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")");
      oStmt.execute(sSQL);

      sSQL = "DELETE FROM " + DB.k_orders_lookup + " WHERE " + DB.gu_owner + "='" + sWrkAreaGUID + "'";
      if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")");
      oStmt.execute(sSQL);
      oStmt.close();
    }

    //-------------------
  // Nuevo para la v5.0

    if (DBBind.exists(oConn, DB.k_quotations, "U")) {
      oStmt = oConn.createStatement();
      try { if (oConn.getDataBaseProduct()!=JDCConnection.DBMS_POSTGRESQL) oStmt.setQueryTimeout(30); } catch (SQLException sqle) {}

    DBSubset oPagSets = new DBSubset(DB.k_quotations, DB.gu_pageset, DB.gu_workarea+"=? AND "+DB.gu_pageset+" IS NOT NULL", 100);
    int nPagSets = oPagSets.load(oConn, new Object[]{sWrkAreaGUID});
    for (int p=0; p<nPagSets; p++) PageSetDB.delete(oConn, oPagSets.getString(0,p));

      sSQL = "DELETE FROM " + DB.k_x_quotations_orders + " WHERE " + DB.gu_quotation + " IN (SELECT "+DB.gu_quotation+" FROM "+DB.k_quotations+" WHERE "+DB.gu_workarea+"='"+sWrkAreaGUID + "')";
      if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")");
      oStmt.execute(sSQL);

      sSQL = "DELETE FROM " + DB.k_quotation_lines + " WHERE " + DB.gu_quotation + " IN (SELECT "+DB.gu_quotation+" FROM "+DB.k_quotations+" WHERE "+DB.gu_workarea+"='"+sWrkAreaGUID + "')";
      if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")");
      oStmt.execute(sSQL);

      sSQL = "DELETE FROM " + DB.k_quotations + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "'";
      if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")");
      oStmt.execute(sSQL);

      sSQL = "DELETE FROM " + DB.k_quotations_next + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "'";
      if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")");
      oStmt.execute(sSQL);
    }

    //-------------------
  // Nuevo para la v4.0

  if (DBBind.exists(oConn, DB.k_warehouses, "U")) {
      oStmt = oConn.createStatement();
      try { if (oConn.getDataBaseProduct()!=JDCConnection.DBMS_POSTGRESQL) oStmt.setQueryTimeout(30); } catch (SQLException sqle) {}

      sSQL = "DELETE FROM " + DB.k_warehouses + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "'";
      if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")");
      oStmt.execute(sSQL);

      oStmt.close();
  }

  if (DBBind.exists(oConn, DB.k_sale_points, "U")) {
      oStmt = oConn.createStatement();
      try { if (oConn.getDataBaseProduct()!=JDCConnection.DBMS_POSTGRESQL) oStmt.setQueryTimeout(30); } catch (SQLException sqle) {}

      sSQL = "DELETE FROM " + DB.k_sale_points + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "'";
      if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")");
      oStmt.execute(sSQL);

      oStmt.close();
  }

  // Fin nuevo para la v4.0
 
    if (DBBind.exists(oConn, DB.k_business_states, "U")) {
      oStmt = oConn.createStatement();
      try { if (oConn.getDataBaseProduct()!=JDCConnection.DBMS_POSTGRESQL) oStmt.setQueryTimeout(30); } catch (SQLException sqle) {}

      sSQL = "DELETE FROM " + DB.k_business_states + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "'";
      if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")");
      oStmt.execute(sSQL);

      sSQL = "DELETE FROM " + DB.k_lu_business_states + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "'";
      if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")");
      oStmt.execute(sSQL);

      oStmt.close();
    }

    if (DBBind.exists(oConn, DB.k_shops, "U")) {
      oItems = new DBSubset (DB.k_shops, DB.gu_shop, DB.gu_workarea + "='" + sWrkAreaGUID + "'", 100);
      iItems = oItems.load(oConn);
      for (int s=0;s<iItems; s++)
        new Shop(oConn, oItems.getString(0,s)).delete(oConn);
    }

    // -----------------------------------------------------------------------------------
    // Nuevos para la v4.0, borrar los eventos

    if (DBBind.exists(oConn, DB.k_events, "U")) {
      oStmt = oConn.createStatement();
      try { if (oConn.getDataBaseProduct()!=JDCConnection.DBMS_POSTGRESQL) oStmt.setQueryTimeout(30); } catch (SQLException sqle) {}
      sSQL = "DELETE FROM " + DB.k_events + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "'";
      if (DebugFile.trace) DebugFile.writeln("Statement.executeUpdate(" + sSQL + ")");
      oStmt.executeUpdate(sSQL);
      oStmt.close();
    }


    // -----------------------------------------------------------------------------------
    // Borrar los jobs

    if (DBBind.exists(oConn, DB.k_jobs, "U")) {
      oItems = new DBSubset (DB.k_jobs, DB.gu_job, DB.gu_workarea + "='" + sWrkAreaGUID + "'", 100);
      iItems = oItems.load(oConn);
      for (int s=0;s<iItems; s++)
        Job.delete(oConn, oItems.getString(0,s));
    }

    // -----------------------------------------------------------------------------------
    // Borrar los eventos

    if (DBBind.exists(oConn, DB.k_events, "U")) {
      oStmt = oConn.createStatement();
      try { if (oConn.getDataBaseProduct()!=JDCConnection.DBMS_POSTGRESQL) oStmt.setQueryTimeout(30); } catch (SQLException sqle) {}
      sSQL = "DELETE FROM " + DB.k_events + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "'";
      if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")");
      oStmt.execute(sSQL);
      oStmt.close();
    }

    // -----------------------------------------------------------------------------------

    // Borrar campos definidos por los usuarios
    if (DBBind.exists(oConn, DB.k_lu_meta_attrs, "U")) {
      oStmt = oConn.createStatement();
      try { if (oConn.getDataBaseProduct()!=JDCConnection.DBMS_POSTGRESQL) oStmt.setQueryTimeout(30); } catch (SQLException sqle) {}
      sSQL = "DELETE FROM " + DB.k_lu_meta_attrs + " WHERE " + DB.gu_owner + "='" + sWrkAreaGUID + "'";
      if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")");
      oStmt.execute(sSQL);
      oStmt.close();
    }

    // -----------------------------------------------------------------------------------
    // Borrar las direcciones

    oStmt = oConn.createStatement();
    try { if (oConn.getDataBaseProduct()!=JDCConnection.DBMS_POSTGRESQL) oStmt.setQueryTimeout(30); } catch (SQLException sqle) {}

    sSQL = "UPDATE " + DB.k_orders + " SET " + DB.gu_ship_addr + "=NULL WHERE " + DB.gu_ship_addr + " IN (SELECT " + DB.gu_address + " FROM " + DB.k_addresses + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "')";
    if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")");
    oStmt.execute(sSQL);

    sSQL = "UPDATE " + DB.k_orders + " SET " + DB.gu_bill_addr + "=NULL WHERE " + DB.gu_bill_addr + " IN (SELECT " + DB.gu_address + " FROM " + DB.k_addresses + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "')";
    if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")");
    oStmt.execute(sSQL);

    sSQL = "DELETE FROM " + DB.k_x_contact_addr + " WHERE " + DB.gu_address + " IN (SELECT " + DB.gu_address + " FROM " + DB.k_addresses + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "')";
    if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")");
    oStmt.execute(sSQL);

    sSQL = "DELETE FROM " + DB.k_x_company_addr + " WHERE " + DB.gu_address + " IN (SELECT " + DB.gu_address + " FROM " + DB.k_addresses + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "')";
    if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")");
    oStmt.execute(sSQL);

    sSQL = "DELETE FROM " + DB.k_addresses + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "'";
    if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")");
    oStmt.execute(sSQL);

    sSQL = "DELETE FROM " + DB.k_addresses_lookup + " WHERE " + DB.gu_owner + "='" + sWrkAreaGUID + "'";
    if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")");
    oStmt.execute(sSQL);

    oStmt.close();

    // -----------------------------------------------------------------------------------

    // Borrar las entradas del tesauro
    if (DBBind.exists(oConn, DB.k_thesauri, "U")) {
      oStmt = oConn.createStatement();
      try { if (oConn.getDataBaseProduct()!=JDCConnection.DBMS_POSTGRESQL) oStmt.setQueryTimeout(30); } catch (SQLException sqle) {}

      // Primero los sinonimos
      sSQL = "DELETE FROM " + DB.k_thesauri + " WHERE " + DB.bo_mainterm + "=0 AND " + DB.gu_rootterm + " IN (SELECT " + DB.gu_rootterm + " FROM " + DB.k_thesauri_root + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "')";

      if (DebugFile.trace) DebugFile.writeln("Statement.executeUpdate(" + sSQL + ")");
      oStmt.executeUpdate(sSQL);

      // Luego los términos principales
      sSQL = "DELETE FROM " + DB.k_thesauri + " WHERE " + DB.gu_rootterm + " IN (SELECT " + DB.gu_rootterm + " FROM " + DB.k_thesauri_root + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "')";

      if (DebugFile.trace) DebugFile.writeln("Statement.executeUpdate(" + sSQL + ")");
      oStmt.executeUpdate(sSQL);

      // Finalmente los terminos raiz
      sSQL = "DELETE FROM " + DB.k_thesauri_root + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "'";

      if (DebugFile.trace) DebugFile.writeln("Statement.executeUpdate(" + sSQL + ")");
      oStmt.executeUpdate(sSQL);

      oStmt.close();
    }

    // Borrar los lookups del tesauro
    if (DBBind.exists(oConn, DB.k_thesauri_lookup, "U")) {
      oStmt = oConn.createStatement();
      try { if (oConn.getDataBaseProduct()!=JDCConnection.DBMS_POSTGRESQL) oStmt.setQueryTimeout(30); } catch (SQLException sqle) {}
      sSQL = "DELETE FROM " + DB.k_thesauri_lookup + " WHERE " + DB.gu_owner + "='" + sWrkAreaGUID + "'";
      if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")");
      oStmt.execute(sSQL);
      oStmt.close();
    }

    // -----------------------------------------------------------------------------------
    // Borrar las cuentas bancarias

    if (DBBind.exists(oConn, DB.k_bank_accounts, "U")) {
      oStmt = oConn.createStatement();
      try { if (oConn.getDataBaseProduct()!=JDCConnection.DBMS_POSTGRESQL) oStmt.setQueryTimeout(30); } catch (SQLException sqle) {}
      sSQL = "DELETE FROM " + DB.k_bank_accounts + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "'";
      if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")");
      oStmt.execute(sSQL);
      oStmt.close();
    }

    if (DBBind.exists(oConn, DB.k_bank_accounts_lookup, "U")) {
      oStmt = oConn.createStatement();
      try { if (oConn.getDataBaseProduct()!=JDCConnection.DBMS_POSTGRESQL) oStmt.setQueryTimeout(30); } catch (SQLException sqle) {}
      sSQL = "DELETE FROM " + DB.k_bank_accounts_lookup + " WHERE " + DB.gu_owner + "='" + sWrkAreaGUID + "'";
      if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")");
      oStmt.execute(sSQL);
      oStmt.close();
    }

    // -----------------------------------------------------------------------------------
    // Borrar los cursos
    // nuevo v2.2

    if (DBBind.exists(oConn, DB.k_absentisms_lookup, "U")) {
      oStmt = oConn.createStatement();
      try { if (oConn.getDataBaseProduct()!=JDCConnection.DBMS_POSTGRESQL) oStmt.setQueryTimeout(30); } catch (SQLException sqle) {}
      sSQL = "DELETE FROM " + DB.k_absentisms_lookup + " WHERE " + DB.gu_owner + "='" + sWrkAreaGUID + "'";
      if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")");
      oStmt.execute(sSQL);
      oStmt.close();
    }

    if (DBBind.exists(oConn, DB.k_subjects, "U")) {
      oStmt = oConn.createStatement();
      try { if (oConn.getDataBaseProduct()!=JDCConnection.DBMS_POSTGRESQL) oStmt.setQueryTimeout(30); } catch (SQLException sqle) {}
      sSQL = "DELETE FROM " + DB.k_subjects_lookup + " WHERE " + DB.gu_owner + "='" + sWrkAreaGUID + "'";
      if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")");
      oStmt.executeUpdate(sSQL);
      sSQL = "DELETE FROM " + DB.k_subjects + " WHERE " + DB.gu_workarea + "='" + sWrkAreaGUID + "'";
      if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")");
      oStmt.executeUpdate(sSQL);
      oStmt.close();
    }

    if (DBBind.exists(oConn, DB.k_courses, "U")) {
      oStmt = oConn.createStatement();
      try { if (oConn.getDataBaseProduct()!=JDCConnection.DBMS_POSTGRESQL) oStmt.setQueryTimeout(30); } catch (SQLException sqle) {}
      sSQL = "DELETE FROM " + DB.k_courses_lookup + " WHERE " + DB.gu_owner + "='" + sWrkAreaGUID + "'";
      if (DebugFile.trace) DebugFile.writeln("Statement.execute(" + sSQL + ")");
      oStmt.executeUpdate(sSQL);
      oStmt.close();

      oItems = new DBSubset (DB.k_courses, DB.gu_course, DB.gu_workarea + "='" + sWrkAreaGUID + "'", 100);
      iItems = oItems.load(oConn);
      if (oConn.getDataBaseProduct()==JDCConnection.DBMS_POSTGRESQL) {
        oPtmt = oConn.prepareStatement("SELECT k_sp_del_course(?)");
        for (int c=0; c<iItems; c++) {
          oPtmt.setString(1, oItems.getString(0,c));
          oPtmt.executeQuery();
        }
        oPtmt.close();
      }
      else {
        oCall = oConn.prepareCall("{call k_sp_del_course (?)}");
       for (int c=0;c<iItems; c++) {
         oCall.setString(1, oItems.getString(0,c));
         oCall.execute();
       }
       oCall.close();
      } // fi (DBMS_POSTGRESQL)
    } // fi (exists(DB.k_courses))

    if (DBBind.exists(oConn, DB.k_education_institutions, "U")) {
      oStmt = oConn.createStatement();
View Full Code Here

   * @param sUserId GUID of User
   * @throws SQLException
   */
  public static boolean isAdmin(JDCConnection oConn, String guWorkArea, String sUserId) throws SQLException {
    int iIsAdmin;
    CallableStatement oCall;
    PreparedStatement oStmt;
    ResultSet oRSet;

    if (DebugFile.trace) {
      DebugFile.writeln("Begin WorkArea.isAdmin([Connection], " + guWorkArea + "," + sUserId + ")");
      DebugFile.incIdent();
    }

    switch (oConn.getDataBaseProduct()) {

      case JDCConnection.DBMS_ORACLE:

        if (DebugFile.trace)
          DebugFile.writeln("Connection.prepareCall({ call k_is_workarea_admin ('" + guWorkArea + "','" + sUserId + "',?)})");

        oCall = oConn.prepareCall("{ call k_is_workarea_admin (?,?,?)}");

        oCall.setString(1, guWorkArea);
        oCall.setString(2, sUserId);
        oCall.registerOutParameter(3, Types.DECIMAL);
        oCall.execute();
        iIsAdmin = oCall.getBigDecimal(3).intValue();
        oCall.close();
        break;

      case JDCConnection.DBMS_MSSQL:
      case JDCConnection.DBMS_MYSQL:

        if (DebugFile.trace)
          DebugFile.writeln("Connection.prepareCall({ call k_is_workarea_admin ('" + guWorkArea + "','" + sUserId + "',?)})");

        oCall = oConn.prepareCall("{ call k_is_workarea_admin (?,?,?)}");

        oCall.setString(1, guWorkArea);
        oCall.setString(2, sUserId);
        oCall.registerOutParameter(3, Types.INTEGER);
        oCall.execute();
        iIsAdmin = oCall.getInt(3);
        oCall.close();
        break;

      default:

        if (DebugFile.trace)
View Full Code Here

   * @throws SQLException
   */

  public static boolean isUser(JDCConnection oConn, String guWorkArea, String sUserId) throws SQLException {
    int iIsUser;
    CallableStatement oCall;
    PreparedStatement oStmt;
    ResultSet oRSet;

    if (DebugFile.trace) {
      DebugFile.writeln("Begin WorkArea.isUser([Connection], " + guWorkArea + "," + sUserId + ")");
      DebugFile.incIdent();
    }

    switch (oConn.getDataBaseProduct()) {

      case JDCConnection.DBMS_ORACLE:

        oCall = oConn.prepareCall("{ call k_is_workarea_user (?,?,?)}");

        oCall.setString(1, guWorkArea);
        oCall.setString(2, sUserId);
        oCall.registerOutParameter(3, Types.DECIMAL);
        oCall.execute();
        iIsUser = oCall.getBigDecimal(3).intValue();
        oCall.close();
        break;

      case JDCConnection.DBMS_MSSQL:
      case JDCConnection.DBMS_MYSQL:

        oCall = oConn.prepareCall("{ call k_is_workarea_user (?,?,?)}");

        oCall.setString(1, guWorkArea);
        oCall.setString(2, sUserId);
        oCall.registerOutParameter(3, Types.INTEGER);
        oCall.execute();
        iIsUser = oCall.getInt(3);
        oCall.close();
        break;

      default:
        oStmt = oConn.prepareStatement("SELECT x." + DB.gu_acl_group + " FROM " + DB.k_x_group_user + " x, " + DB.k_x_app_workarea + " w WHERE x." + DB.gu_acl_group + "=w." + DB.gu_users + " AND x." + DB.gu_user + "=? AND w." + DB.gu_workarea + "=?", ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
        oStmt.setString(1, sUserId);
View Full Code Here

  public static int currVal(JDCConnection oConn, String sSequenceName)
      throws SQLException, UnsupportedOperationException {

    Statement oStmt;
    ResultSet oRSet;
    CallableStatement oCall;
    int iCurrVal;

    if (DebugFile.trace)
      {
      DebugFile.writeln("Begin hipergate DBBind.currVal([JDCConnection], " + sSequenceName + ")" );
      DebugFile.incIdent();
      }

    switch (oConn.getDataBaseProduct()) {

      case JDCConnection.DBMS_MYSQL:
      case JDCConnection.DBMS_MSSQL:

        if (DebugFile.trace) DebugFile.writeln("Connection.prepareCall({call k_sp_currval ('" + sSequenceName + "',?)})" );

        oCall = oConn.prepareCall("{call k_sp_currval (?,?)}");
        oCall.setString(1, sSequenceName);
        oCall.registerOutParameter(2, java.sql.Types.INTEGER);
        oCall.execute();
        iCurrVal = oCall.getInt(2);
        oCall.close();
        oCall = null;
        break;

      case JDCConnection.DBMS_POSTGRESQL:
        oStmt = oConn.createStatement();
View Full Code Here

TOP

Related Classes of java.sql.CallableStatement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.