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