Force Oracle error on fetch

Posted by Dan on Stack Overflow See other posts from Stack Overflow or by Dan
Published on 2010-05-14T16:09:18Z Indexed on 2010/05/15 1:54 UTC
Read the original article Hit count: 416

Filed under:
|
|

I am trying to debug a strange behavior in my application. In order to do so, I need to reproduce a scenario where an SQL SELECT query will throw an error, but only while actually fetching from the cursor, not while executing the query itself. Can this be done? Any error will do, but ORA-01722: invalid number seems like the obvious one to try.

I created a table with the follwing:

KEYCOL INTEGER PRIMARY KEY
OTHERCOL VARCHAR2(100)

I then created a few hundred rows with unique values for the primary key and the value l for the othercol. I then ran a SELECT * query, picked a row somewhere in the middle, and updated it to the string abcd. I ran the query SELECT KEYCOL, TO_NUMBER(OTHERCOL) FROM SOMETABLE hoping to get some rows of good data an then an error later. But I keep getting ORA-01722: invalid number on the execute step itself.

I have gotten this behavior programmatically using ADO (with server-side cursor) and JDBC, as well as from PL/SQL Developer. How can I get the result I'm looking for? thanks

Edit - meant to add, when using ADO, I am only calling Command.Execute. I am not creating or opening a Recordset.

© Stack Overflow or respective owner

Related posts about Oracle

Related posts about sql