Re: Dynamic sql in esql/c
Posted in 1992
In article <3855@wet.UUCP> dror@wet.UUCP (dror matalon) writes: > > 1. I can't open a cursor order by for update....Why? Because ordering implies a sort and the return of rows from a temporary table created by the sort. Potentially a very long time lag between OPEN and the FETCH of the first row. Hence in order to allow update with order-by while maintaining integrity, the engine would have to (a) retain info on the original location of each sorted row and (b) lock each original selected row before sorting it, and keep the locks as long as the cursor was open. > ...Any ideas for work arounds. The best is to not require updating in some sequence; the serial dependency implied is counter to the relational model. However, the usual workaround is to make the ordered cursor not for update, but to have a second cursor that fetches only a single row, by rowid, for update. Open it, fetch it, re-verify the row needs updating, update where current, and close. [lots deleted which I didn't understand, sorry] > I might just have to hack this and generate code to create an array > of struct sqlvar_struct _sqobind[] and imitate the way > esqlc does the binding, but I hate doing this kind of things mainly > when they're bound to change with each upgrade. This is not a hack, but rather the standard, supported approach. Read the manual on DESCRIBE and ALLOCATE DESCRIPTOR.