Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Vfp50 - Select SQL
Message
De
22/03/1997 11:29:35
 
 
À
21/03/1997 08:26:03
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00024860
Message ID:
00025281
Vues:
32
>>>>>How can I...
>>>>>"SELECT * FROM table INTO CURSOR anycursor"
>>>>>and make changes to anycursor that are reflectd
>>>>>back to my table. Can you SELECT INTO A CURSOR VIEW?
>>>>
>>>>As far as I know, you can only change the source table if yu use a view. Queries and cursors are snapshots of the data. This means that you would need to use "select SQL view"
>>>
>>>Thanks Mike...
>>>How would I (code wise) change this code:
>>>"select * from table into cursor mycursor" to a "select view"
>>>so my users can edit the cursor?
>>
>>CREATE SQL VIEW myview as select * from table
>>
>>Then create a form using myview in the data environment.
>>If you dreate the view in the view designer, you can set it to allow SQL updates so that the user can edit the source data. If you do it in code you need to use SETCURSORPROP I think.
>>Mike
>
>Thanks Mike...So, what you are saying is, if I have "myview" created in
>the view designer and then, in my program, I say:
>CREATE SQL VIEW myview AS SELECT * FROM TABLE,
>
>the view MYVIEW gets updated on the fly?

Nope. You can create a view either by using the CREATE SQL VIEW in code, or by using the view designer. Either way you will end up with a view. If you look in the data section of the project manager you will see the view myview listed. You only need to run the CREATE SQL VIEW once. After that you need to requery the view when you use it. If you ask the user for information in a form, and you want your view to be different depending on the user's answer eg all entries before a certain date, then you need to use a parameterised view. This means that in the SQL code you would have

CREATE SQL VIEW myview as select * from table
WHERE table.date < ?mydate

mydate would be the variable that you use to store the user's answer. (You need the ?)
I you then use requery(), the view will show the values before this date.

If you just want the user to be able to edit the view that you have created in a form or browse, but allow the updates to occur in the source table then you must check send SQL updates in the update criteria page of the view designer.
If you use code you must use

CURSORSETPROP(SendUpdates,.T.) to allow the updates.
To recap,
Once you have created your view, (and only once), and requeried it if necessary, then run your form which will have your view as it's data environment. The edits that your user makes will be reflected in the source table.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform