1 5 8 package com.teamkonzept.webman.mainint.db.queries.oracle; 9 10 import java.sql.*; 11 12 import com.teamkonzept.db.*; 13 import com.teamkonzept.webman.mainint.WebmanExceptionHandler; 14 import com.teamkonzept.webman.mainint.db.queries.presentation.*; 15 16 24 public class TKDBPresInsert extends TKExtendedPrepQuery 25 { 26 27 public final static boolean isPrepared = true; 28 29 public final static String [] order = 30 { "PRESENTATION_NAME", "PRESENTATION_SHORTNAME", 31 "TEMPLATE_ID" 32 }; 33 34 public final static Object [][] types = 35 { {"PRESENTATION_NAME", new Integer (Types.VARCHAR)}, 36 {"PRESENTATION_SHORTNAME", new Integer (Types.VARCHAR)} 37 }; 38 39 public final static boolean[] setRelevants = { true }; 40 41 66 67 protected static Class [] queryClasses = { 68 SelectMaxPresentation.class, 69 InsertPresentation.class, 70 SelectPresentation.class 71 }; 72 73 public boolean execute() 74 { 75 try 76 { 77 init(queryClasses); 78 79 boolean isNotOpen = aTKDBConnection.isAutoCommit(); 80 if (isNotOpen) 81 { 82 TKDBManager.beginTransaction(); 83 } 84 85 queries[0].execute(); 87 int pid = 0; 88 ResultSet rs = queries[0].fetchResultSet(); 89 if (rs != null && rs.next()) 90 { 91 pid = rs.getInt(1) + 1; 92 } 93 Integer presentationId = new Integer (pid); 94 95 queries[1].setQueryParams("PRESENTATION_ID", presentationId); 97 queries[1].setQueryParams("PRESENTATION_NAME", 98 queryParams.get("PRESENTATION_NAME")); 99 queries[1].setQueryParams("PRESENTATION_SHORTNAME", 100 queryParams. 101 get("PRESENTATION_SHORTNAME")); 102 queries[1].setQueryParams("TEMPLATE_ID", 103 queryParams.get("TEMPLATE_ID")); 104 queries[1].execute(); 105 queries[2].setQueryParams("PRESENTATION_ID", presentationId); 107 queries[2].execute(); 108 addResult(queries[2].fetchResultSet()); 109 110 if (isNotOpen) 111 { 112 TKDBManager.commitTransaction(); 113 } 114 115 } 116 catch(Throwable t) 117 { 118 TKDBManager.safeRollbackTransaction(t); 119 } 120 return hasResults(); 121 } 122 123 public void initQuery(Connection con) 124 { 125 super.initQuery(con, isPrepared, order, types, setRelevants, null); 126 } 127 } 128 | Popular Tags |