General information
Category:
Databases,Tables, Views, Indexing and SQL syntax
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
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only