Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create a Read/Write cursor in SQL 1

Status
Not open for further replies.

AndrewMozley

Programmer
Oct 15, 2005
623
GB
An application creates a cursor for subsequent output to an Excel file with :

SELECT * FROM Table1 WHERE <condition> ;
INTO CURSOR Cursor2

I would then like to refine the table, recalculating certain fields in Cursor2.

However I cannot do this. When I try I get "Cannot update the cursor" because the cursor is Read-only; that is what this version of the SQL command produces.

I believe that I could get round this by sending the output INTO a table. I would however need to define a temporary name for this table and then delete it at the end.

Since I am lazy, is there a way that I can arrange for a cursor produced by the SELECT - SQL command to be updateable.

Thanks. Andrew M.
 
It always could help if you tell us what version of VFP you use.
Because in VFP8 there is READWRITE clause in SELECT-SQL:
Code:
SELECT * FROM Table1 WHERE <condition> ;
      INTO CURSOR Cursor2 READWRITE

In previous versions you could do something like:
Code:
SELECT * FROM Table1 WHERE <condition> ;
      INTO CURSOR CursorTemp NOFILTER
USE (DBF([CursorTemp])) ALIAS Cursor2 AGAIN IN 0 SHARED
USE IN SELECT([CursorTemp])
SELECT Cursor2



Borislav Borissov
VFP9 SP1, SQL Server 2000/2005.
MVP VFP
 
Thank you Borisslav.

This application was on VFP6, so I take your point. (I do also have VFP8)

Just to make sure I understand your example, are the square brackets necessary, or are they part of the notation? I only ask because on line 2, . . . INTO CURSOR CursorTemp . . . no square brackets are shown.

Thanks for a very prompt reply.
 
Square brackets are a third kind of string delimiters in VFP. They are needed, or ' or ", as DBF() and SELECT() functions are used here and have a cAlias parameter.

Bye, Olaf.
 
yes, the square brackets are just string delimiters.

Borislav Borissov
VFP9 SP1, SQL Server 2000/2005.
MVP VFP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top