Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
EDITing OR APPENDing to LOCAL VIEWS
Message
De
25/11/1999 11:34:40
 
 
À
24/11/1999 19:55:06
John Vlahos
V I Software Solutions Design
Mississauga, Ontario, Canada
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00295056
Message ID:
00295576
Vues:
19
>2) Customer_Ship_To Table Primary Index: CustCode + ShipToCode

This might not pertain to your problem, but I would like to give you a warning about compound primary keys. In general, this is a bad practice. A table should have a unique, surrogate key that can be used in update operations, and any other time a unique record must be identified. There are lots of reasons for this- all of which will become evident the more you build database apps.


>Within the LOAD() event of my main customer form (frmCustomer) I code the following:
>USE CUSTOMER_SHIP_TO IN 0 ORDER TAG SHIPTO OF CUSTOMER_SHIP_TO
>CURSORSETPROP("Buffering", 3, "CUSTOMER_SHIP_TO")
>USE CUSTOMER IN 0 ORDER TAG CUSTCODE OF CUSTOMER
>CURSORSETPROP("Buffering", 3, "CUSTOMER")
>USE lvCustomer_Ship_To IN 0

Unless you have a separate set of controls that are bound to the underlying tables, or need them for another reason, you don't need to open the view's underlying tables in addition to the view. Doing so, and especially turning buffering on for those tables, causes a double-buffering situation where updates from the view are simply sent to the buffered copy of. To write the changes back to disk, you would also have to issue a TABLEUPDATE() on the tables after TABLEUPDATEing the view.

>B. .If I remove an address by issuing a DELETE and a TABLEUPDATE(0,.T.) it removes itself from the grid; If I then re-add the same SHIPTOCODE for that Customer, I get a "Unique violation" error...this probably has something to do with my "Primary Index Key"...why do I get this? I just previously deleted it? It is actually unique.

Primary key indexes enforce uniqueness for EVERY record in the table, deleted or not. (The persistence of a deleted record is a uniquely xBase concept, but you'll have to get used to it. Once you come to grasp that the records are still there until you PACK, this feature can actually come in quite handy). since your primary key for this table is a compound of the keys for two other tables, this strategy is going to cause trouble for you, because you will never be able to add that record again (reason #1 from my advice above).


>c. If I add a completely new SHIPTo code it is not visible within my grid. I issue a TABLEUPDATE(0,.T.) after every addition. I also issue a REQUERY("lvCustomer_Ship_To") after every TABLEUDATE(0,.T.) along with a ThisForm.grdCustomer_Ship_To.Refresh(). The data is actually stored in the bas table CUSTOMER_SHIP_TO. I checked. If I close all the forms and reopen them I see the additions. Closing the frmCustomer_Ship_To form is not enough. I must close and reopen the main frmCustomer form also.


Not sure what is happening here. Let's get your first 2 problems worked out first, and the cause of this one will probably become more evident.

>I apologize for this lenghtly reply, but I am failry new to VFP....It is the first time I am using Local Views. I find them pretty frustrating.

They can be confusing at first, but stick with it, they can be very useful. They're one of my favorite tools.
Erik Moore
Clientelligence
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform