01: package com.teamkonzept.webman.mainint.db.queries.duplication;
02:
03: import com.teamkonzept.db.*; //import com.teamkonzept.lib.*;
04:
05: import java.io.*;
06: import java.util.*;
07: import java.sql.*;
08:
09: /**
10: * fügt an die Namen aller Knoten im Sitetree unterhalb des Knotens
11: * mit ID ROOT_ID
12: * die Erweiterung NAME_EXT an, vorne wenn POS == 0, sonst hinten.
13: * SITE_NODE_NAME und SITE_NODE_SHORTNAME werden veraendert
14: */
15: public class TKDBSiteTreeRenameRecursive extends TKPrepQuery {
16:
17: public final static boolean isPrepared = true;
18:
19: public final static String[] paramOrder = { "NAME_EXT", "POS",
20: "ROOT_ID" };
21:
22: public final static Object[][] paramTypes = { { "NAME_EXT ",
23: new Integer(Types.VARCHAR) } };
24:
25: public final static boolean[] setRelevants = null;
26:
27: public final static String sqlString =
28:
29: /* Vorne oder hinten anhŠngen einer Namenserweiterung im Site Tree bei allen Kindern eines Nodes */
30:
31: " DECLARE @NAME_EXT varchar(100) "
32: + " DECLARE @ROOT_ID int "
33: + " DECLARE @RIGHT_NR int "
34: + " DECLARE @LEFT_NR int "
35: + " DECLARE @POS int "
36:
37: + " SELECT @NAME_EXT = ? "
38: + " SELECT @POS = ? "
39: + " SELECT @ROOT_ID = ? "
40: + " SELECT @RIGHT_NR = RIGHT_NR "
41: + " FROM SITE_TREE "
42: + " WHERE "
43: + " SITE_NODE_ID = @ROOT_ID "
44:
45: + " SELECT @LEFT_NR = LEFT_NR "
46: + " FROM SITE_TREE "
47: + " WHERE "
48: + " SITE_NODE_ID = @ROOT_ID "
49: + " IF (@POS = 0) "
50: + " BEGIN " /* vorne anfuegen */
51: + " UPDATE SITE_TREE "
52: + " set SITE_NODE_NAME = stuff(SITE_NODE_NAME, 1, 0, @NAME_EXT) "
53: + " WHERE LEFT_NR > @LEFT_NR "
54: + " AND "
55: + " RIGHT_NR < @RIGHT_NR "
56:
57: + " UPDATE SITE_TREE "
58: + " set SITE_NODE_SHORTNAME = stuff(SITE_NODE_SHORTNAME, 1, 0, @NAME_EXT) "
59: + " WHERE LEFT_NR > @LEFT_NR "
60: + " AND "
61: + " RIGHT_NR < @RIGHT_NR "
62: + " END "
63: + " ELSE "
64: + " BEGIN " /* hinten anfuegen */
65: + " UPDATE SITE_TREE "
66: + " set SITE_NODE_NAME = stuff(@NAME_EXT, 1, 0, SITE_NODE_NAME) "
67: + " WHERE LEFT_NR > @LEFT_NR "
68: + " AND "
69: + " RIGHT_NR < @RIGHT_NR "
70:
71: + " UPDATE SITE_TREE "
72: + " set SITE_NODE_SHORTNAME = stuff(@NAME_EXT, 1, 0, SITE_NODE_SHORTNAME) "
73: + " WHERE LEFT_NR > @LEFT_NR " + " AND "
74: + " RIGHT_NR < @RIGHT_NR " + " END ";
75:
76: public void initQuery(Connection con) {
77: super.initQuery(con, isPrepared, paramOrder, paramTypes,
78: setRelevants, sqlString);
79: }
80: }
|