Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VFP 6.0 sql select to cursor
Message
From
02/03/2000 08:12:52
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00340471
Message ID:
00340474
Views:
27
James,

>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.

You need to transform the cursor to readwrite in fox.

The following function can be used. Note that if you are using field names greater than 10 characters they will be truncated.

FUNCTION TransformToReadWriteCursor
PARAMETERS tcCursName
LOCAL lcTempCurs

lcTempCurs = "FoxTemp"+SUBSTR(SYS(2015), 3, 10)

SELECT 0
USE FULLPATH( DBF( tcCursName)) AGAIN ALIAS (lcTempCurs)
USE IN ( tcCursName)

SELECT 0
USE FULLPATH( DBF(lcTempCurs)) AGAIN ALIAS (tcCursName)
USE IN (lcTempCurs)
SELECT (tcCursName)


The other alternative is to write a stored procedure in SQL which does the replace in the cursor for you, and then return the results set.

Cheers
Steve Lea
Previous
Reply
Map
View

Click here to load this message in the networking platform