This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

fetch out of sequence  RSS feed

 
Tia Wai
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I'm trying simple loading of an image file into Oracle as a Blob, but keep getting the error:ORA-01002: fetch out of sequence.
The code is as follows:
BLOB blob = null;
stmt.execute("CREATE TABLE img (name varchar(10), data blob)");
stmt.execute("INSERT INTO img VALUES ('test', empty_blob())");
stmt.execute("commit");
String cmd = "SELECT * FROM img WHERE name='test' FOR UPDATE";
ResultSet rset = stmt.executeQuery(cmd);
while(rset.next())
blob = ((OracleResultSet)rset).getBLOB(2);
What am I doing wrong?? Please help!
Thanks.
 
Jamie Robertson
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
taken from the oracle docs:
Error Message: "ORA-01002: fetch out of sequence"
A JDBC Connection by default has the AutoCommit turned ON. However, to use a SQL that has 'for update' you need to have autoCommit to be turned OFF.
Hence, the solution is to set autocommit to false.
http://otn.oracle.com/tech/java/sqlj_jdbc/htdocs/jdbc_faq.htm#_18_
Jamie
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!