Re: Ordered update cursors?
Posted in 1993
>From: uunet!cyclone.atl.ga.us!esa >Subject: Ordered update cursors? >Date: Tue, 9 Feb 1993 19:36:19 GMT >To: informix-list@rmy.emory.edu >X-Informix-List-Id: <news.2621> >According to the Informix SQL reference and tutorial manuals, the >select statement associated with an update cursor may not include >an "order by" clause. I'm curious as to why and what workarounds >are possible to achieve the same effect. Basically, because the engine may have to sort the data, and it therefore may be working on a copy of the selected data, not the original data. The normal way around this is to set up two cursors, one with ORDER BY but no FOR UPDATE, and the other with FOR UPDATE and no ORDER BY. The sorting cursor selects the primary key info (or ROWID) and enough data to allow the ordering to work. The update cursor uses the PK info or ROWID to fetch one row for update. This means that you can process the data in the order you want, but you also get the necessary locking by using the update cursor. Yours, Jonathan Leffler (johnl@obelix.informix.com) #include <disclaimer.h>