Article View: borland.public.vdbase.data.sql
Article #1550Re: Updating Related Keys
From: Joe Yuzamas
Date: Fri, 21 Nov 1997 00:00
Date: Fri, 21 Nov 1997 00:00
74 lines
2570 bytes
2570 bytes
Daniel
The simple way would be to replace the seek and replace with the following
SQL;
UPDATE ORDERS SET CUSTOMER = :cNewStore ;
WHERE CUSTOMER = :cOldStore
Don't worry about indexs, they take care of them selves.
--
Joe < jyuzamas@wrdiss1.robins.af.mil or jyuzamas@sprynet.com >
Daniel Howard <sproket@total.net> wrote in article
<34466D8E.53A1@total.net>...
> Hello all!
>
> This is I'm sure a simple problem. I just haven't figured out how to do
> this.
>
> I'm in a situation where my users would like the ability to modify keys
> in their supplier and customer masterfiles (the keys are short 10
> character versions of the supplier/customer names).
>
> I setup the maintenance form so that in the onOpen and OnNavigate
> methods, the key's original values are stored to properties and in the
> OnClose and CanNavigate Methods I check to see if they've changed.
>
> I then need to open the order file and replace the keys so I use code
> like this:
>
> Procedure UpdateStoreKeys(cOld,cNew)
> local f
>
> cOldStore = cOld
> cNewStore = cNew
>
> set procedure to UpdateKey.wfm addi
>
> create session
>
> f = New UpdateKeyForm()
> f.Text = "Updating Keys..."
> f.Text1.Text = "Updating Store Keys in Orders..."
> f.View = ":ORDERS:ORDERS"
> f.Open()
>
> set database to orders
> oldError = setto("ON ERROR")
>
> set order to tag customer
> RollBack = .f.
> on error do RollItBack
> begintrans()
> seek(cOldStore)
> replace all orders->customer with cNewStore ;
> while orders->customer = cOldStore
> if RollBack
> rollback()
> else
> commit()
> endif
> on error &oldError.
> release object f
> return
>
> It only replaces the 1st record in the orders file. I assume that when
> the record gets changed it changes the order of the table in the loop so
> the next record immediately falls out of scope.
>
> Any ideas on how to make this work?
>
> TIA
>
Technical Details
Message-ID:
<01bcf6b3$9c330720$1030f489@jyuzamas.robins.af.mil>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<34466D8E.53A1@total.net>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: ff5a1,637a3bf0e23a423d,start X-Google-Attributes: gidff5a1,public From: "Joe Yuzamas" <jyuzamas@wrdiss1.robins.af.mil> Subject: Re: Updating Related Keys Date: 1997/11/21 Message-ID: <01bcf6b3$9c330720$1030f489@jyuzamas.robins.af.mil> X-Deja-AN: 291279458 References: <34466D8E.53A1@total.net> Organization: U.S. Air Force Newsgroups: borland.public.vdbase.data.sql