Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Append from view
Message
 
À
30/03/1999 09:53:52
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00203367
Message ID:
00207694
Vues:
9
>how can i make an append from a view into a table in vfp 5.0??

If you are talking about using a cursor or a temporary table, please see all the other replies. If you are talking about using a local view in a DBC to either append or update a record, there are multiple things you must do (forgive me in advance if I don't remember every step off the top of my head):
1) Create the updatable view. The easiest way to do this is through the "Create local view" option off of the right-click menu when working within your DBC. Make sure you pay special attention to the last pageframe which tells your DBC whether the view is updatable or not. The key option on this pageframe is "Send Updates". Make sure that the checkbox is checked. You must also designate a primary key. You can also do this same thing programmatically with the CURSORSETPROP at run-time and with the DBSETPROP commands
2) Open the local view, just like you would any other table. If you are appending, then you'll probably want to open the view without any data in it.

USE MyDBC!MyView IN 0 NODATA

3) Append records to your heart's content. Each record added will have a RECNO() that is negative. By default, local views open in optimistic row buffering turned on. This is important, because every time you move the record pointer or close the view (via USE), the view will try to update the underlying table in the DBC. You can control this by placing all your appends in a transaction (see BEGIN TRANSACTION,END TRANSACTION, ROLLBACK in help). My preferred way is to use optimistic table buffering (=CURSORSETPROP("Buffering",5,"MyView")) in . Now, the only time the view tries to update the underlying table in the DBC, is when you close the view or you explicitly issue a TABLUPDATE() command.

Example:
USE MyDBC!MyView IN 0 NODATA

WHILE {you wish to append}
APPEND BLANK IN MyView or INSERT INTO MyView () VALUES ()
ENDWHILE

*-- Add data to table
BEGIN TRANSACTION
*-- Some other view manipulations
IF TABLEUPDATE("MyView")
*-- Table was updated
END TRANSACTION
ELSE
*-- Table was not updated properly. Rollback any changes
ROLLBACK
ENDIF
USE IN MyView

This is just my suggestion. There are multiple valid ways to do this same thing. It all depends on your personal style and performance impact on your application(s).

My biggest suggestion is looking at the help for:
BEGIN TRANSACTION/END TRANSACTION/ROLLBACK
TABLEUPDATE
TABLEREVERT
CURSORGETPROP/CURSORSETPROP
DBGETPROP/DBSETPROP
I would give my left arm to be ambidextrous!
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform