01: package com.teamkonzept.webman.mainint.db.queries.duplication.oracle;
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: " DECLARE "
31: + " name_ext VARCHAR2(100); "
32: + " root_id INTEGER; "
33: + " root_right INTEGER; "
34: + " root_left INTEGER; "
35: + " pos INTEGER; "
36: + " BEGIN "
37: + " name_ext := ?; "
38: + " pos := ?; "
39: + " root_id := ?; "
40:
41: + " SELECT RIGHT_NR INTO root_right "
42: + " FROM SITE_TREE "
43: + " WHERE "
44: + " SITE_NODE_ID = root_id; "
45:
46: + " SELECT LEFT_NR INTO root_left "
47: + " FROM SITE_TREE "
48: + " WHERE "
49: + " SITE_NODE_ID = root_id; "
50: + " IF (pos = 0) THEN "
51: + " " /* vorne anfuegen */
52: + " UPDATE SITE_TREE "
53: + " SET SITE_NODE_NAME = name_ext || SITE_NODE_NAME "
54: + " WHERE LEFT_NR > root_left "
55: + " AND "
56: + " RIGHT_NR < root_right; "
57:
58: + " UPDATE SITE_TREE "
59: + " SET SITE_NODE_SHORTNAME = name_ext || SITE_NODE_SHORTNAME "
60: + " WHERE LEFT_NR > root_left "
61: + " AND "
62: + " RIGHT_NR < root_right; "
63: + " ELSE "
64: + " " /* hinten anfuegen */
65: + " UPDATE SITE_TREE "
66: + " SET SITE_NODE_NAME = SITE_NODE_NAME || name_ext "
67: + " WHERE LEFT_NR > root_left "
68: + " AND "
69: + " RIGHT_NR < root_right; "
70:
71: + " UPDATE SITE_TREE "
72: + " set SITE_NODE_SHORTNAME = SITE_NODE_SHORTNAME || name_ext "
73: + " WHERE LEFT_NR > root_left "
74: + " AND "
75: + " RIGHT_NR < root_right; " + " END IF; "
76: + " END; "
77:
78: ;
79:
80: public void initQuery(Connection con) {
81: super.initQuery(con, isPrepared, paramOrder, paramTypes,
82: setRelevants, sqlString);
83: }
84: }
|