Update question
Posted in 1993
This is probably an RTFM and I may be shot down in flames into the
nether-worlds of the net, but can someone explain why I need a "for update"
for the cursor?...
>...when I ran the program, first thing it said was that I needed a
>'for update' for the cursor. The second, fatal problem is that you
>cannot do a foreach without doing a begin work.
>
>I'll copy the program into this in case you can't remember it.
>You don't need to do anything more with this. I've pretty much
>accepted that you can't do a foreach without a begin work and, therefore,
>you can't do a commit after every transaction. Oh well.
>
>
> O /
> \\/
> /\\ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> O \\
>
> database standard
>
> main
> define p_vendor record like stpvendr.*, ---(1)
> p_terms record like terms.*,
> h_term like stpvendr.terms_code
>
> declare cur_vend cursor with hold for select * from stpvendr
> foreach cur_vend into p_vendor.*
> select d_terms_code into h_term from terms
> where d_vend_no = p_vendor.vend_code
> if (h_term <> p_vendor.terms_code) then
> begin work
> update stpvendr set terms_code = h_term
> where current of cur_vend
> message "Updated vendor ", p_vendor.vend_code
> if status <> 0 then
> message "Unable to update ", p_vendor.vend_code
> rollback work
> else
> commit work
> end if
> end if
> end foreach
>end main>
--
See the happy moron, ... Clay Irving personal: clay@panix.com
He doesn't give a damn, ... New York, NY work: clay@garpac.com
I wish I were a moron, ....................................................
My God! perhaps I am! -- Eugenics Review July 1929