| ObjectArrayExampleAddBookingsObjectArray.java |
1 package com.orindasoft.demo.generated.plsql;
2
3 import java.sql.*;
4
5 // From oracle 9.0.1 "oracle.jdbc.driver" is deprecated and
6 // its contents move to "oracle.jdbc". "oracle.jdbc.driver"
7 // still exists in 9.2.0.
8 import oracle.jdbc.OracleTypes;
9 // import oracle.jdbc.driver.OracleTypes;
10
11 import com.orindasoft.pub.LogInterface;
12 import com.orindasoft.pub.OracleResourceUser;
13 import com.orindasoft.pub.CSException;
14 import com.orindasoft.demo.generated.plsql.AbstractProcCall;
15
16 /**
17 * ObjectArrayExampleAddBookingsObjectArray - Access Procedure OBJECT_ARRAY_EXAMPLE.ADD_BOOKINGS_OBJECT_ARRAY
18 *
19 * <p>Generated by JDBCWizard./a> build 2776 at 2011/03/07 19:55:34.221 GMT
20 * <p>JDBCWizard./a> is made by Orinda Software Ltd, Dublin, Ireland
21 * <p>Target Database: Oracle 10.2.0
22 * <p> -------------------------------------------------------------------------
23 * <p> WARNING: This code will stop working around the time JDBCWizard./a> expires.
24 * <p> This restriction only exists in the demo version of JDBCWizard./a>.
25 * <p> -------------------------------------------------------------------------
26 * <p> JDBCWizard./a> Tips 13 of 19:
27 * <p> JDBCWizard./a> understands how CLOBs, BLOBS and BFILES work in Oracle.
28 * <p> -------------------------------------------------------------------------
29 *
30 * <p>Copyright Orinda Software 2003-2009
31 * <p>Access Basis: User Object
32 * <p>PLSQL source code:
33 * <code><pre>
34 -----------------------------------------------------------------
35 * PACKAGE OBJECT_ARRAY_EXAMPLE AS
36 * /*
37 * THIS EXAMPLE SHOWS HOW TO CALL PL/SQL PROCEDURE THAT TAKES AN ARRAY DEFINED
38 * AS AN ORACLE TYPE OBJECT AS A PARAMETER.
39 *
40 * WE CALL THIS DIRECTLY FROM JAVA USING JDBC AND A CLASS THAT IS REPRESENTED
41 * BY ORACLE.SQL.ARRAY. OUR GENERATED JAVA CLASS WILL USE THE JDBC INTERFACE
42 * ORACLE.SQL.DATUM
43 *
44 * --
45 * -- P_CITY IS THE SAME DATA TYPE AS THE COLUMN DEPARTURE_CITY IN THE FLIGHTS TABLE.
46 * -- P_FLIGHTS_FROM USES THE ORACLE TYPE OBJECT FLIGHTS_TABLE.
47 * --
48 * PROCEDURE GET_OBJECT_ARRAY_OF_FLIGHTS(P_CITY IN FLIGHTS.DEPARTURE_CITY%TYPE
49 * ,P_FLIGHTS_FROM OUT NOCOPY FLIGHTS_TABLE);
50 * --
51 * PROCEDURE ADD_BOOKINGS_OBJECT_ARRAY (P_CUSTOMER IN CUSTOMERS%ROWTYPE
52 * ,P_BOOKING_TABLE IN BOOKINGS_TABLE
53 * ,P_STATUS_MESSAGE OUT NOCOPY VARCHAR2);
54 * --
55 * END;
56 -----------------------------------------------------------------
57 * </pre></code>
58 * @author devteam60@orindabuild.com
59 * @version 1.1
60 */
61 public class ObjectArrayExampleAddBookingsObjectArray extends AbstractProcCall implements OracleResourceUser
62 {
63
64 /**
65 * Variable to store P_CUSTOMER
66 */
67 public Customers paramPCustomer = null;
68
69 /**
70 * Variable to store P_BOOKING_TABLE
71 */
72 public BookingsTable paramPBookingTable = null;
73
74 /**
75 * Variable to store P_STATUS_MESSAGE
76 */
77 public String paramPStatusMessage = null;
78
79 /**
80 * The name of the procedure or function we will access.
81 * This name be actually refer to a synonym or somebody else's code
82 */
83 public static final String procName = "OBJECT_ARRAY_EXAMPLE.ADD_BOOKINGS_OBJECT_ARRAY";
84
85 /**
86 * Procedure Type
87 * What kind of function this is.
88 */
89 public static final int PROC_TYPE = AbstractProcCall.THIS_USERS_OBJECT;
90
91 /**
92 * Procedure call text
93 * The anonymous PL/SQL block that we use to run the procedure.
94 * This used to be a String but we now use a StringBuffer because
95 * procCall can be > 64K. We fill this in on first use.
96 */
97 private StringBuffer procCall = null;
98
99 /**
100 * Constructor that calls the Constructor of AbstractProcCall
101 *
102 */
103 public ObjectArrayExampleAddBookingsObjectArray (Connection theConnection, LogInterface theLog)
104 {
105 super(theConnection, theLog);
106 theLog.debug("ObjectArrayExampleAddBookingsObjectArray started"); //DEBUG
107 }
108
109
110 /**
111 * Method to set parameter P_CUSTOMER
112 * @param Customers paramPCustomer
113 */
114 public void setParamPCustomer(Customers paramPCustomer)
115 {
116 this.paramPCustomer = paramPCustomer;
117 }
118
119 /**
120 * Method to set parameter P_CUSTOMER to null
121 */
122 public void setParamPCustomerToNull()
123 {
124 this.paramPCustomer = null;
125 }
126
127 /**
128 * Method to set parameter P_BOOKING_TABLE
129 * @param BookingsTable paramPBookingTable
130 */
131 public void setParamPBookingTable(BookingsTable paramPBookingTable)
132 {
133 this.paramPBookingTable = paramPBookingTable;
134 }
135
136 /**
137 * Method to set parameter P_BOOKING_TABLE to null
138 */
139 public void setParamPBookingTableToNull()
140 {
141 this.paramPBookingTable = null;
142 }
143
144
145 /**
146 * Method to get P_STATUS_MESSAGE
147 * @return String
148 */
149 public String getParamPStatusMessage()
150 {
151 if (paramPStatusMessage == null)
152 {
153 return(null);
154 }
155
156 return (new String(paramPStatusMessage.toString()));
157 }
158
159
160 /**
161 * Unload OUT parameters
162 */
163 protected void getStatementResults() throws CSException
164 {
165 theLog.debug("Starting to unload data");
166
167 theParameters.unloadParameters(theCallableStatement);
168
169 // Unload parameter P_STATUS_MESSAGE
170
171 theLog.debug("Unloading parameter paramPStatusMessage" );
172 paramPStatusMessage = (String)theParameters.getParam(9);
173
174 try
175 {
176 theCallableStatement.clearParameters();
177 theParameters.clearParameters();
178 }
179 catch (SQLException e)
180 {
181 throw (new CSException("getStatementResults: Unable to clear parameters:" + e.toString()));
182 }
183 theLog.debug("Finished unloading data");
184 }
185
186
187
188 /**
189 * Associate parameters with statement
190 */
191 protected void bindParams() throws CSException
192 {
193 theLog.debug("Starting to bind parameters");
194 // Make sure P_BOOKING_TABLE is not null
195 if (paramPBookingTable == null)
196 {
197 paramPBookingTable = new BookingsTable(theLog);
198 }
199
200 // Bind parameter P_CUSTOMER
201 // Prevent null pointer exception later on
202 if (paramPCustomer == null)
203 {
204 paramPCustomer = new Customers(theLog);
205 }
206
207 // Bind parameter NAME
208
209 theLog.debug("binding input parameter paramPCustomer.paramName to position 1");
210 theParameters.setParam(1,paramPCustomer.paramName);
211 // Bind parameter ADDRESS
212
213 theLog.debug("binding input parameter paramPCustomer.paramAddress to position 2");
214 theParameters.setParam(2,paramPCustomer.paramAddress);
215 // Bind parameter CITY
216
217 theLog.debug("binding input parameter paramPCustomer.paramCity to position 3");
218 theParameters.setParam(3,paramPCustomer.paramCity);
219 // Bind parameter STATE
220
221 theLog.debug("binding input parameter paramPCustomer.paramState to position 4");
222 theParameters.setParam(4,paramPCustomer.paramState);
223 // Bind parameter ZIP
224
225 theLog.debug("binding input parameter paramPCustomer.paramZip to position 5");
226 theParameters.setParam(5,paramPCustomer.paramZip);
227 // Bind parameter BIRTHDATE
228
229 theLog.debug("binding input parameter paramPCustomer.paramBirthdate to position 6");
230 if (paramPCustomer.paramBirthdate != null)
231 {
232 theParameters.setParam(6,paramPCustomer.paramBirthdate);
233 }
234 else
235 {
236 theParameters.setParam(6,(java.util.Date)null);
237 }
238 // Bind parameter PHONE
239
240 theLog.debug("binding input parameter paramPCustomer.paramPhone to position 7");
241 theParameters.setParam(7,paramPCustomer.paramPhone);
242 // Bind parameter P_BOOKING_TABLE
243
244 theLog.debug("binding input parameter paramPBookingTable to position 8");
245 try
246 {
247 theParameters.setPlSqlTableArrayParam(8,paramPBookingTable);
248 }
249 catch (Exception e)
250 {
251 throw (new CSException("PL/SQL Array Input Parameter paramPBookingTable could not be loaded:" + e.toString()));
252 }
253
254 // Bind parameter P_STATUS_MESSAGE
255 theLog.debug("binding output parameter paramPStatusMessage to position 9" );
256 theParameters.setOutParam(9,OracleTypes.VARCHAR);
257 theLog.debug("Associating parameters with statement");
258 theParameters.bindParameters(theCallableStatement);
259 theLog.debug("Finished binding parameters");
260 }
261
262
263 /**
264 * Return a SQL statement that will invoke this stored procedure
265 * This may be a synonym or owned by somebody else.
266 *
267 */
268 public String getProcCallStatement()
269 {
270 if (procCall == null)
271 {
272 procCall = new StringBuffer("DECLARE \n"); // 1
273 procCall.append("/* Created By JDBCWizard./a> 6.0.2776 */ \n"); // 2
274 procCall.append("/* Which can be obtained at www.orindasoft.com */ \n"); // 3
275 procCall.append("p_customer CUSTOMERS%ROWTYPE; \n"); // 4
276 procCall.append("p_booking_table BOOKINGS_TABLE; \n"); // 5
277 procCall.append("p_status_message VARCHAR2(4000) := null; \n"); // 6
278 procCall.append("BEGIN \n"); // 7
279 procCall.append("p_customer.name := ?; \n"); // 8
280 procCall.append("p_customer.address := ?; \n"); // 9
281 procCall.append("p_customer.city := ?; \n"); // 10
282 procCall.append("p_customer.state := ?; \n"); // 11
283 procCall.append("p_customer.zip := ?; \n"); // 12
284 procCall.append("p_customer.birthdate := ?; \n"); // 13
285 procCall.append("p_customer.phone := ?; \n"); // 14
286 procCall.append("p_booking_table := ?; \n"); // 15
287 procCall.append("p_status_message := null; \n"); // 16
288 procCall.append(" \n"); // 17
289 procCall.append("OBJECT_ARRAY_EXAMPLE.ADD_BOOKINGS_OBJECT_ARRAY(p_customer => p_customer,p_booking_table => p_booking_table,p_status_message => p_status_message); \n"); // 18
290 procCall.append("? := p_status_message; \n"); // 19
291 procCall.append("END; "); // 20 569 characters
292
293 }
294 return(procCall.toString());
295 }
296
297} // Generated by JDBCWizard./a> 6.0.2776
298