Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VFP 6.0 sql select to cursor
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00340471
Message ID:
00340480
Views:
50
>Hello Everyone,
>
>Is it possible to use a sql select to create a cursor and then do a replace in a field in the cursor. I tried this as below but get a 'CANNOT UPDATE THE CURSOR' error message.
>
>
>select name, section from tablename into cursor mycursor
>select mycursor
>replace all section with "A" for section = "V"
>
>I only want to change the values in the cursor, not the original table, and I intend to use the cursor for a report form.
>
>Can anyone help me with this issue?


The proper way would be to select into a table. Your job becomes destroy the newly-created table when you're done with it.

With a SQL Select based on a single table, where the query is fully optimized, you may be getting a filtered view rather than an actual cursor; if you did anything to update it the results would be devastating, since your underlying store is the actual base table. You have to add the NOFILTER clause to the SELECT to ensure that this does not happen.

Once you have a real cursor, replace the "select mycursor" with:

USE (DBF()) AGAIN IN 0 ALIAS MyCursor2
USE
SELECT MyCursor2

MyCursor2, the re-use of the cursor in a new area, should be writable, and should go away when you release it via USE/CLOSE DATA or the like.

You can alter the initial SELECT to result in MyCursor being writable by making the code appear as follows:

select name, section from tablename into cursor (SYS(2015)) NOFILTER
USE (DBF()) AGAIN IN 0 ALIAS MyCursor
USE
SELECT MyCursor
replace all section with "A" for section = "V"
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform