need to copy the value of an Oracle long column from one table to
another. I have been able to accomplish this by querying the source
table and using the result set
String temporaryLong = rs.getString(1)
to store the value into a string.
To put the value into the destination I create a String Reader on my
string
StringReader str = new StringReader(temporaryLong);
dstStmt.setCharacterStream(1, str, temporaryLong.length());
and send it via a character stream.
On big long columns storing the long as a string takes up an awful lot
of memory and is fairly slow. Is there a way to take the character
stream from the result set of the source table and feed it directly to
the character stream of the destination?
Here is the actual snippet of code:
srcStmt = conn.prepareStatement(
" SELECT "+longColumn+", "+pkColumn
+ " FROM " + srcTable + " src"
+ " WHERE src."+pkColumn+" = TO_NUMBER(?)");
srcStmt.setString(1,pkValue);
srcResult = srcStmt.executeQuery();
if (srcResult.next()) {
temporaryLong = srcResult.getString(1);
if (srcResult.wasNull()) {
temporaryLong="";
}
dstStmt = conn.prepareStatement(
" INSERT INTO " + dstTable
+ " (" + longColumn + "," + pkColumn + ")"
+ " VALUES(?, TO_NUMBER(?))");
StringReader str = new StringReader(temporaryLong);
dstStmt.setCharacterStream(1, str, temporaryLong.length());
dstStmt.setString(2, pkValue);
result = dstStmt.executeUpdate();
dstStmt.close();
Thanks,
Dave
__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, more
http://taxes.yahoo.com/
---
You are currently subscribed to jdjlist as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]
http://www.sys-con.com/fusetalk