Re: Please help: invalid cursor state error ???
Posted in 1998
On Thu, 13 Aug 1998 filtrasucur@my-dejanews.com wrote: > I need some help here. > > I'm using esqlc and cursors in a program that should update a field from a > table, but I get this error message: SQLSTATE code 24000: INVALID CURSOR > STATE. > > And this is what I do: > > EXEC SQL declare micursor cursor for > select login into :login > from otp_users > where id_mode ="N" > for update of login; > > I open the cursor and then there's a loop with this (among other things): > > EXEC SQL fetch micursor into :login; > > EXEC SQL update otp_users set login= :login > where current of micursor; > > > Besides, if the cursor is declared with the "for update" statement I get > nothing when I print out the content of the login variable. > > What am I doing wrong? Not showing us what the 'among other things' are :-) For example, you could most easily get that error by using a COMMIT WORK or ROLLBACK WORK in amongst the other things. You also don't show us what your erro handling strategy is -- do you know that the DECLARE worked? Did the OPEN work? Did the FETCH work? If you don't yet have an error handling strategy, the first step (crude, nasty, effective) is to add: EXEC SQL WHENEVER ERROR STOP; in front of your declare statement. That way, you'll know when things first start going wrong. Yours, Jonathan Leffler (jleffler@informix.com) #include <witticism.h> Guardian of DBD::Informix v0.60 -- http://www.perl.com/CPAN Informix IDN for D4GL & Linux -- http://www.informix.com/idn