01: /*
02: * $Header: /cvsroot/webman-cms/source/webman/com/teamkonzept/webman/mainint/db/queries/sybase/Attic/TKDBPresContInsert.java,v 1.2 2001/08/15 12:50:09 markus Exp $
03: *
04: */
05: /**
06: * Jedes Selectstatement erhaelt eine eigene Klasse
07: */package com.teamkonzept.webman.mainint.db.queries.sybase;
08:
09: import java.sql.*;
10:
11: import com.teamkonzept.db.*;
12:
13: /*
14: * TKDBPresContInsert
15: * input "PRESENTATION_ID", "COMPONENT_TYPE", "INTEGRATION_TYPE",
16: * "INTEGRATION_NAME", "INTEGRATION_SHORTNAME", "FORM_ID",
17: *
18: * ouptut neu erzeugter DS aus PRESENTATION_CONTENT
19: *
20: * erzeugt neuen Eintrag in PRESENTATION_COMPONENT + PRESENTATION_CONTENT
21: */
22: public class TKDBPresContInsert extends TKPrepQuery {
23:
24: public final static boolean isPrepared = true;
25:
26: public final static String[] paramOrder = { "PRESENTATION_ID",
27: "COMPONENT_TYPE", "INTEGRATION_TYPE", "INTEGRATION_NAME",
28: "INTEGRATION_SHORTNAME", "FORM_ID" };
29:
30: public final static Object[][] paramTypes = {
31: { "INTEGRATION_NAME", new Integer(Types.VARCHAR) },
32: { "INTEGRATION_SHORTNAME", new Integer(Types.VARCHAR) } };
33:
34: public final static boolean[] setRelevants = { true };
35:
36: public final static String sqlString = "DECLARE @PIDX int "
37: + "DECLARE @PID int " +
38:
39: "SELECT @PID = ? " +
40:
41: "BEGIN TRANSACTION " +
42:
43: "SELECT "
44: + " @PIDX=ISNULL(MAX(PRESENTATION_COMPONENT_IDX)+1, 0) "
45: + "FROM " + " PRESENTATION_COMPONENT " + "WHERE "
46: + " PRESENTATION_ID = @PID " +
47:
48: "INSERT INTO " + " PRESENTATION_COMPONENT "
49: + " (PRESENTATION_ID, PRESENTATION_COMPONENT_IDX, "
50: + " COMPONENT_TYPE, INTEGRATION_TYPE, "
51: + " INTEGRATION_NAME, INTEGRATION_SHORTNAME) " + "VALUES "
52: + " (@PID, @PIDX, ?, ?, ?, ?) " +
53:
54: "INSERT INTO " + " PRESENTATION_CONTENT "
55: + " (PRESENTATION_ID, PRESENTATION_COMPONENT_IDX, "
56: + " FORM_ID) " + "VALUES " + " (@PID, @PIDX, ?) " +
57:
58: "SELECT " + " * " + "FROM " + " PRESENTATION_CONTENT "
59: + "WHERE " + " PRESENTATION_ID = @PID " + "AND "
60: + " PRESENTATION_COMPONENT_IDX = @PIDX " +
61:
62: "COMMIT ";
63:
64: public void initQuery(Connection con) {
65: super.initQuery(con, isPrepared, paramOrder, paramTypes,
66: setRelevants, sqlString);
67: }
68: }
|