| ObjectArrayExampleGetObjectArrayOfFlights.java |
1 package com.orindasoft.demo.generated.plsql;
2
3 import java.sql.*;
4
5 import com.orindasoft.pub.LogInterface;
6 import com.orindasoft.pub.OracleResourceUser;
7 import com.orindasoft.pub.CSException;
8 import com.orindasoft.demo.generated.plsql.AbstractProcCall;
9
10 /**
11 * ObjectArrayExampleGetObjectArrayOfFlights - Access Procedure OBJECT_ARRAY_EXAMPLE.GET_OBJECT_ARRAY_OF_FLIGHTS
12 *
13 * <p>Generated by JDBCWizard./a> build 2776 at 2011/03/07 19:55:34.538 GMT
14 * <p>JDBCWizard./a> is made by Orinda Software Ltd, Dublin, Ireland
15 * <p>Target Database: Oracle 10.2.0
16 * <p> -------------------------------------------------------------------------
17 * <p> WARNING: This code will stop working around the time JDBCWizard./a> expires.
18 * <p> This restriction only exists in the demo version of JDBCWizard./a>.
19 * <p> -------------------------------------------------------------------------
20 * <p> JDBCWizard./a> Tips 11 of 19:
21 * <p> JDBCWizard./a> can write Java to run any SQL statement. In step 2.2.3.1
22 * <p> You tell JDBCWizard./a> which directory you keep your .SQL files in.
23 * <p> Provided you have 1 statement per file it will then generate a Java class
24 * <p> to run each statement. Within a file bind variables can be specified using
25 * <p> either '?' or '&'.
26 * <p> -------------------------------------------------------------------------
27 *
28 * <p>Copyright Orinda Software 2003-2009
29 * <p>Access Basis: User Object
30 * <p>PLSQL source code:
31 * <code><pre>
32 -----------------------------------------------------------------
33 * PACKAGE OBJECT_ARRAY_EXAMPLE AS
34 * /*
35 * THIS EXAMPLE SHOWS HOW TO CALL PL/SQL PROCEDURE THAT TAKES AN ARRAY DEFINED
36 * AS AN ORACLE TYPE OBJECT AS A PARAMETER.
37 *
38 * WE CALL THIS DIRECTLY FROM JAVA USING JDBC AND A CLASS THAT IS REPRESENTED
39 * BY ORACLE.SQL.ARRAY. OUR GENERATED JAVA CLASS WILL USE THE JDBC INTERFACE
40 * ORACLE.SQL.DATUM
41 *
42 * --
43 * -- P_CITY IS THE SAME DATA TYPE AS THE COLUMN DEPARTURE_CITY IN THE FLIGHTS TABLE.
44 * -- P_FLIGHTS_FROM USES THE ORACLE TYPE OBJECT FLIGHTS_TABLE.
45 * --
46 * PROCEDURE GET_OBJECT_ARRAY_OF_FLIGHTS(P_CITY IN FLIGHTS.DEPARTURE_CITY%TYPE
47 * ,P_FLIGHTS_FROM OUT NOCOPY FLIGHTS_TABLE);
48 * --
49 * PROCEDURE ADD_BOOKINGS_OBJECT_ARRAY (P_CUSTOMER IN CUSTOMERS%ROWTYPE
50 * ,P_BOOKING_TABLE IN BOOKINGS_TABLE
51 * ,P_STATUS_MESSAGE OUT NOCOPY VARCHAR2);
52 * --
53 * END;
54 -----------------------------------------------------------------
55 * </pre></code>
56 * @author devteam60@orindabuild.com
57 * @version 1.1
58 */
59 public class ObjectArrayExampleGetObjectArrayOfFlights extends AbstractProcCall implements OracleResourceUser
60 {
61
62 /**
63 * Variable to store P_CITY
64 */
65 public String paramPCity = null;
66
67 /**
68 * Variable to store P_FLIGHTS_FROM
69 */
70 public FlightsTable paramPFlightsFrom = null;
71
72 /**
73 * The name of the procedure or function we will access.
74 * This name be actually refer to a synonym or somebody else's code
75 */
76 public static final String procName = "OBJECT_ARRAY_EXAMPLE.GET_OBJECT_ARRAY_OF_FLIGHTS";
77
78 /**
79 * Procedure Type
80 * What kind of function this is.
81 */
82 public static final int PROC_TYPE = AbstractProcCall.THIS_USERS_OBJECT;
83
84 /**
85 * Procedure call text
86 * The anonymous PL/SQL block that we use to run the procedure.
87 * This used to be a String but we now use a StringBuffer because
88 * procCall can be > 64K. We fill this in on first use.
89 */
90 private StringBuffer procCall = null;
91
92 /**
93 * Constructor that calls the Constructor of AbstractProcCall
94 *
95 */
96 public ObjectArrayExampleGetObjectArrayOfFlights (Connection theConnection, LogInterface theLog)
97 {
98 super(theConnection, theLog);
99 theLog.debug("ObjectArrayExampleGetObjectArrayOfFlights started"); //DEBUG
100 }
101
102
103 /**
104 * Method to set parameter P_CITY
105 * @param String paramPCity
106 */
107 public void setParamPCity(String paramPCity)
108 {
109 this.paramPCity = paramPCity;
110 }
111
112 /**
113 * Method to set parameter P_CITY to null
114 */
115 public void setParamPCityToNull()
116 {
117 this.paramPCity = null;
118 }
119
120
121 /**
122 * Method to get P_FLIGHTS_FROM
123 * @return FlightsTable
124 */
125 public FlightsTable getParamPFlightsFrom()
126 {
127 return(paramPFlightsFrom);
128 }
129
130
131 /**
132 * Unload OUT parameters
133 */
134 protected void getStatementResults() throws CSException
135 {
136 theLog.debug("Starting to unload data");
137
138 theParameters.unloadParameters(theCallableStatement);
139
140 // Unload parameter P_FLIGHTS_FROM
141
142 // Unload paramPFlightsFrom
143 theLog.debug("Unloading parameter paramPFlightsFrom" );
144 paramPFlightsFrom = (FlightsTable)theParameters.getParam(2);
145
146 try
147 {
148 theCallableStatement.clearParameters();
149 theParameters.clearParameters();
150 }
151 catch (SQLException e)
152 {
153 throw (new CSException("getStatementResults: Unable to clear parameters:" + e.toString()));
154 }
155 theLog.debug("Finished unloading data");
156 }
157
158
159
160 /**
161 * Associate parameters with statement
162 */
163 protected void bindParams() throws CSException
164 {
165 theLog.debug("Starting to bind parameters");
166 // Make sure P_FLIGHTS_FROM is not null
167 if (paramPFlightsFrom == null)
168 {
169 paramPFlightsFrom = new FlightsTable(theLog);
170 }
171
172 // Bind parameter P_CITY
173
174 theLog.debug("binding input parameter paramPCity to position 1");
175 theParameters.setParam(1,paramPCity);
176 // Bind parameter P_FLIGHTS_FROM
177 theLog.debug("binding output parameter paramPFlightsFrom to position 2" );
178 theParameters.setPlSqlTableArrayOutParam(2,paramPFlightsFrom);
179 theLog.debug("Associating parameters with statement");
180 theParameters.bindParameters(theCallableStatement);
181 theLog.debug("Finished binding parameters");
182 }
183
184
185 /**
186 * Return a SQL statement that will invoke this stored procedure
187 * This may be a synonym or owned by somebody else.
188 *
189 */
190 public String getProcCallStatement()
191 {
192 if (procCall == null)
193 {
194 procCall = new StringBuffer("DECLARE \n"); // 1
195 procCall.append("/* Created By JDBCWizard./a> 6.0.2776 */ \n"); // 2
196 procCall.append("/* Which can be obtained at www.orindasoft.com */ \n"); // 3
197 procCall.append("p_city VARCHAR2(16) := ?; \n"); // 4
198 procCall.append("p_flights_from FLIGHTS_TABLE; \n"); // 5
199 procCall.append("BEGIN \n"); // 6
200 procCall.append(" \n"); // 7
201 procCall.append("OBJECT_ARRAY_EXAMPLE.GET_OBJECT_ARRAY_OF_FLIGHTS(p_city => p_city,p_flights_from => p_flights_from); \n"); // 8
202 procCall.append("? := p_flights_from; \n"); // 9
203 procCall.append("END; "); // 10 274 characters
204
205 }
206 return(procCall.toString());
207 }
208
209} // Generated by JDBCWizard./a> 6.0.2776
210