Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cursor... Read only?

Status
Not open for further replies.

DrD123

IS-IT--Management
Jan 23, 2003
111
US
Hi... I almost have my delete program working... but when I test it at the DB2> prompt or in a KSH with db2 -ao preceding the SQL commands, I get a message that cursor I declared is Read-Only or not positioned on a row(whether I use with hold or not).
The column w/UI is a date field, not time-stamp. Here's the query:
declare X1 cursor with hold for select col_with_UI from HUGE_TABLE where days(CURRENT DATE) - days(col_with_UI)>:host_var1 for update of col_with_UI.
I've also tried:
declare X1 cursor for select col_with_UI from HUGE_TABLE where days(CURRENT DATE) - days(col_with_UI)>:host_var1
And:
declare X1 cursor with hold for select col_with_index_from _same_table from HUGE_TABLE where days(CURRENT DATE) - days(col_with_UI)>:host_var1 for update of select col_with_index_from _same_table
And when I do a fetch I get results plus sqlstate:00000
When I do the delete I get either sqlstate: 24504 or sqlstate: 24501.
Any ideas? Can I even get real results via the DB2> prompt or a KSH, or do I have to compile before I test it?
Just an FYI the delete statement is:
delete from HUGE_TABLE where current of X1
Thank you,
DrD123
 
The simple answer, to the best of my knowledge, is that cursors are for use within application programs and not within interactive environments. In other words, yes, you have to compile and execute your program in order to test your cursor logic.

Ever onward,
jar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top