001: /*
002: * $Header: /cvsroot/webman-cms/source/webman/com/teamkonzept/webman/mainint/db/queries/sybase/Attic/TKDBPresDelete.java,v 1.2 2001/08/15 12:50:09 markus Exp $
003: *
004: */
005: /**
006: * Jedes Selectstatement erhaelt eine eigene Klasse
007: */package com.teamkonzept.webman.mainint.db.queries.sybase;
008:
009: import java.sql.*;
010:
011: import com.teamkonzept.db.*;
012: import com.teamkonzept.webman.mainint.WebmanExceptionHandler;
013: import com.teamkonzept.webman.mainint.db.queries.presentation.*;
014:
015: /*
016: * TKDBPresDelete
017: * input "PRESENTATION_ID"
018: * output none
019: * loescht aus PRESENTATION sowie alle referentiellen Verweise
020: */
021: public class TKDBPresDelete extends TKExtendedPrepQuery {
022:
023: public static boolean isPrepared = true;
024:
025: public static String[] order = { "PRESENTATION_ID" };
026:
027: public static Object[][] types = null;
028:
029: public static boolean[] setRelevants = { false };
030:
031: /* public final static String sqlString =
032: "DECLARE @PID int " +
033: "SELECT @PID = ? " +
034:
035: "BEGIN TRANSACTION " +
036:
037: "DELETE FROM " +
038: " PRESENTATION_REFERENCE " +
039: "WHERE " +
040: " PRESENTATION_ID = @PID " +
041:
042: "DELETE FROM " +
043: " PRESENTATION_CONTENT " +
044: "WHERE " +
045: " PRESENTATION_ID = @PID " +
046:
047: "DELETE FROM " +
048: " PRESENTATION_COMPONENT " +
049: "WHERE " +
050: " PRESENTATION_ID = @PID " +
051:
052: "DELETE FROM " +
053: " PRESENTATION " +
054: "WHERE " +
055: " PRESENTATION_ID = @PID " +
056:
057: "COMMIT "; */
058:
059: protected static Class[] queryClasses = {
060: DeleteFromPresentationReferenceSimple.class,
061: DeleteFromPresentationContentSimple.class,
062: DeleteFromPresentationComponentSimple.class,
063: DeleteFromPresentationSimple.class };
064:
065: public boolean execute() {
066: try {
067: init(queryClasses);
068:
069: Integer presId = (Integer) queryParams
070: .get("PRESENTATION_ID");
071:
072: boolean isNotOpen = aTKDBConnection.isAutoCommit();
073: if (isNotOpen) {
074: TKDBManager.beginTransaction();
075: }
076:
077: // DELETE FROM PRESENTATION_REFERENCE WHERE PRESENTATION_ID = @PID
078: queries[0].setQueryParams("PRESENTATION_ID", presId);
079: queries[0].execute();
080:
081: // DELETE FROM PRESENTATION_CONTENT WHERE PRESENTATION_ID = @PID
082: queries[1].setQueryParams("PRESENTATION_ID", presId);
083: queries[1].execute();
084:
085: // DELETE FROM PRESENTATION_COMPONENT WHERE PRESENTATION_ID = @PID
086: queries[2].setQueryParams("PRESENTATION_ID", presId);
087: queries[2].execute();
088:
089: // DELETE FROM PRESENTATION WHERE PRESENTATION_ID = @PID
090: queries[3].setQueryParams("PRESENTATION_ID", presId);
091: queries[3].execute();
092:
093: if (isNotOpen) {
094: TKDBManager.commitTransaction();
095: }
096:
097: } catch (Throwable t) {
098: TKDBManager.safeRollbackTransaction(t);
099: }
100: return hasResults();
101: }
102:
103: public void initQuery(Connection con) {
104: super.initQuery(con, isPrepared, order, types, setRelevants,
105: null);
106: }
107: }
|