Revision 150
Added by Matt Jones almost 24 years ago
DBSAXDocument.java | ||
---|---|---|
153 | 153 |
pstmt = conn.prepareStatement( |
154 | 154 |
"SELECT nodedata FROM xml_nodes " + |
155 | 155 |
"WHERE nodetype = 'TEXT' " + |
156 |
"AND rootnodeid = ? " + |
|
156 | 157 |
"AND parentnodeid IN " + |
158 |
" (SELECT nodeid FROM xml_nodes " + |
|
159 |
" WHERE nodename = 'title' " + |
|
160 |
" AND nodetype = 'ELEMENT' " + |
|
161 |
" AND rootnodeid = ? ) " + |
|
162 |
"ORDER BY nodeid"); |
|
163 |
|
|
164 |
// The above query might be slow, and probably will be because |
|
165 |
// it gets ALL of the title elements while searching for one |
|
166 |
// title in a small subtree but it avoids the problem of using |
|
167 |
// Oracle's Hierarchical Query syntax which is not portable -- |
|
168 |
// the commented out SQL that follows shows an equivalent query |
|
169 |
// using Oracle-specific hierarchical query |
|
170 |
/* |
|
171 |
pstmt = conn.prepareStatement( |
|
172 |
"SELECT nodedata FROM xml_nodes " + |
|
173 |
"WHERE nodetype = 'TEXT' " + |
|
174 |
"AND parentnodeid IN " + |
|
157 | 175 |
"(SELECT nodeid FROM xml_nodes " + |
158 | 176 |
"WHERE nodename = 'title' " + |
159 | 177 |
"START WITH nodeid = ? " + |
160 | 178 |
"CONNECT BY PRIOR nodeid = parentnodeid)"); |
161 |
/* |
|
162 |
"SELECT nodeid " + |
|
163 |
"FROM xml_nodes " + |
|
164 |
"START WITH nodeid = ? " + |
|
165 |
"CONNECT BY PRIOR nodeid = parentnodeid " + |
|
166 |
"AND PRIOR nodename = 'title' " ); |
|
167 |
|
|
168 |
pstmt = conn.prepareStatement("SELECT nodedata " + |
|
169 |
"FROM xml_nodes " + |
|
170 |
"WHERE nodetype = 'TEXT' " + |
|
171 |
" AND nodeid in " + |
|
172 |
"(SELECT nodeid FROM xml_nodes " + |
|
173 |
" WHERE nodename = 'title' " + |
|
174 |
" START WITH nodeid = ? " + |
|
175 |
" CONNECT BY PRIOR nodeid = parentnodeid "); |
|
176 | 179 |
*/ |
177 | 180 |
|
178 | 181 |
// Bind the values to the query |
179 | 182 |
pstmt.setLong(1, rootnodeid); |
183 |
pstmt.setLong(2, rootnodeid); |
|
180 | 184 |
|
181 | 185 |
pstmt.execute(); |
182 | 186 |
ResultSet rs = pstmt.getResultSet(); |
Also available in: Unified diff
rewrote DBSimpleQuery and associated classes to no longer use Oracle's hierarchichal query syntax -- now this should work with any JDBC compliant backend DB