Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Vfp50 - Select SQL
Message
From
27/03/1997 08:59:27
 
 
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00024860
Message ID:
00025822
Views:
33
>>>>>>>>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.
>>
>>Thanks Mike.. your answer helps... I have a question about CURSORSETPROP(SendUpdates,.T.?
>>Where do I put this code? In the SAVE YOUR CHANGES buton when the user
>>make his changes?
>
>Sorry Robert, I have not been back to my PC for a while. CURSORSETPROP, as the name suggests, sets the properties for the cursor ( or view). If the view is selected, then it will be affected by the CURSORSETPROP function if you issue it in the code, i.e. where you create the view. At the risk of upsetting Edward, you can also issue..
>CURSORSETPROP(SendUpdates,.T.,"MyView")
>Mike

Thanks Mike... To update my VIEW, I had to:

=cursorsetprop("keyfieldlist",'primary key')
=cursorsetprop("sendupdates",.t.,'myview')
=cursorsetprop("updatablefieldlist",'name,acctnum,etc...'myview')

What ever happen to REPLACE name WITH myview->name?
Robert Keith
Independent Developer
San Antonio, Texas
E-mail address:
rebelrob1@yahoo.com
Previous
Reply
Map
View

Click here to load this message in the networking platform