01: /**
02: * Jedes Selectstatement erhaelt eine eigene Klasse
03: */package com.teamkonzept.field.db.queries.sybase;
04:
05: import com.teamkonzept.db.*;
06: import java.sql.*;
07:
08: public class TKDBContentNewLegacy extends TKPrepQuery {
09:
10: public final static boolean IS_PREPARED = true;
11:
12: public final static String[] PARAM_ORDER = { "INSTANCE_ID",
13: "STATUS_ID", "VERS_INFO", "VERS_AUTHOR" };
14:
15: public final static Object[][] PARAM_TYPES = {
16: { "VERS_INFO", new Integer(Types.VARCHAR) },
17: { "VERS_AUTHOR", new Integer(Types.VARCHAR) } };
18:
19: public final static boolean[] SET_RELEVANTS = { true };
20:
21: public final static String SQL_STRING = "DECLARE @VERS_ID INT "
22: + "DECLARE @CONT_ID INT "
23: + "DECLARE @INST_ID INT "
24: + "DECLARE @STAT_ID INT "
25: +
26:
27: "BEGIN TRANSACTION "
28: +
29:
30: "SELECT @INST_ID = ? "
31: + "SELECT @STAT_ID = ? "
32: +
33:
34: "SELECT @VERS_ID=ISNULL(MAX(VERSION_ID)+1, 1) "
35: + "FROM CONTENT_VERSION "
36: +
37:
38: "SELECT @CONT_ID=ISNULL(MAX(CONTENT_ID)+1, 1) "
39: + "FROM CONTENT "
40: +
41:
42: "INSERT INTO CONTENT (CONTENT_ID) "
43: + "VALUES(@CONT_ID) "
44: +
45:
46: "INSERT INTO CONTENT_VERSION (VERSION_ID, INSTANCE_ID, CONTENT_ID, STATUS_ID, VERSION_DATE, INFO, AUTHOR) "
47: + " VALUES (@VERS_ID, @INST_ID, @CONT_ID, @STAT_ID, {fn NOW()}, ?, ?) "
48: +
49:
50: "COMMIT TRANSACTION "
51: +
52:
53: "SELECT CV.*, CI.NAME FROM CONTENT_VERSION CV, CONTENT_INSTANCE CI "
54: + "WHERE CV.VERSION_ID = @VERS_ID AND CI.INSTANCE_ID = @INST_ID ";
55:
56: public void initQuery(Connection con) {
57: super.initQuery(con, IS_PREPARED, PARAM_ORDER, PARAM_TYPES,
58: SET_RELEVANTS, SQL_STRING);
59: }
60: }
|