KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > de > webman > content > workflow > db > queries > sybase > DeleteContent


1 package de.webman.content.workflow.db.queries.sybase;
2
3 import java.sql.*;
4
5 import com.teamkonzept.db.*;
6
7 /**
8  * Aufräumen alter Contentversionen
9  *
10  * ToDo: Wert der CONTENT_ID in CONTENT_VERSION ?? null ?
11     * @author $Author: sebastian $
12     * @version $Revision: 1.2 $
13  */

14 public class DeleteContent extends TKPrepQuery{
15
16     public final static boolean IS_PREPARED =
17         true;
18     
19     public final static String JavaDoc[] PARAM_ORDER =
20         { "CONTENT_ID", "INSTANCE_ID", "CONTENT_ID", "INSTANCE_ID"};
21     
22     public final static Object JavaDoc[][] PARAM_TYPES =
23         null;
24         
25     public final static boolean[] SET_RELEVANTS =
26         { false };
27         
28     public final static String JavaDoc SQL_STRING =
29         "CREATE TABLE #temp (CONTENT_ID int not null) " +
30         "INSERT INTO #temp(CONTENT_ID) SELECT CONTENT_ID FROM CONTENT_VERSION WHERE CONTENT_ID < ? AND INSTANCE_ID = ? " +
31         "UPDATE CONTENT_VERSION SET CONTENT_ID = NULL WHERE CONTENT_ID < ? AND INSTANCE_ID = ? " +
32         "DELETE FROM CONTENT_VALUE WHERE CONTENT_ID IN (SELECT DISTINCT CONTENT_ID FROM #temp) " +
33         "DELETE FROM CONTENT_NODE WHERE CONTENT_ID IN (SELECT DISTINCT CONTENT_ID FROM #temp) " +
34         "DELETE FROM CONTENT WHERE CONTENT_ID IN (SELECT DISTINCT CONTENT_ID FROM #temp) " +
35         "DELETE FROM CONTENT_ATTRIBUTE_VALUE WHERE CONTENT_ID IN (SELECT DISTINCT CONTENT_ID FROM #temp) " +
36         "DELETE FROM CONTENT_ATTRIBUTE WHERE NOT ( VALUE_ID IN (SELECT VALUE_ID FROM CONTENT_ATTRIBUTE_VALUE)) " +
37         "DROP TABLE #temp ";
38     
39     public void initQuery(Connection con) {
40         super.initQuery(
41             con,
42             IS_PREPARED,
43             PARAM_ORDER,
44             PARAM_TYPES,
45             SET_RELEVANTS,
46             SQL_STRING );
47     }
48 }
49
50
Popular Tags