Re: Cursors without Declare?
Posted in 1995
>From: storm@aztec.co.za (Storm Software) >Date: 5 Oct 1995 08:07:37 +0200 >X-Informix-List-Id: <news.17644> > >We installed Version 6.0 4GL the other day and were amazed to find our >application of 7 years fall over on the menu. Investigation found the following > > let p_string = "select * from table" > prepare get_ready from p_string > > declare c_go cursor for get_ready > > open get_ready > fetch get_ready into vars... > >Now, ok, we realised our mistake straight away. We are opening the PREPARE >statement not the cursor. But how come for the last 7 years it worked. One of the weirder parts of the pre-5.00 ESQL/C implementation is that there was barely any distinction between cursors and statements. This is one of the reasons why you only FREE either the cursor or the statement but not both in pre-5.00 ESQL/C. By contrast, in post-5.00 ESQL/C, and therefore in 6.0x I4GL too, there is a real distinction between the two, and this leads to the problem you found. The lack of distinction in pre-5.00 code is one of the reasons why you get a bunch of unused cursor structures _SQn declared in the file. >So I left the cursor bit out (Version 4.13 4GL and below), and true as Bob, >it still works. Does this mean we don't have to DECLARE cursors that have >been pre-prepared. Is there a performance benefit in this Informix? There is a negligible performance benefit at the cost of not being supported. >(BTW, V.6. tells you are attempting a fetch on an unopened cursor) Well, that is somewhat indirect, but it would be correct -- the cursor would not be open because the open should fail because you are not opening a cursor. You should detect an error on the OPEN, I think, though I haven't tested it. Yours, Jonathan Leffler (johnl@informix.com) #include <disclaimer.h>