VFP 6: Getting a Writeable Cursor froma R/O Cursor - xbase
This is a discussion on VFP 6: Getting a Writeable Cursor froma R/O Cursor - xbase ; I have a R/O cursor that is an extract from a table. I need it to be R/W so I can run some a what-if scenario on it. I would rather not create a table since I do not want ...
![]() |
| | LinkBack | Thread Tools | Display Modes |
|
#1
| |||
| |||
| to be R/W so I can run some a what-if scenario on it. I would rather not create a table since I do not want to keep the data. How can I create a R/W version of the cursor that I have? Failing that, how can I create a R/W extract from a table? (The original table must not be modified by the subsequent writes.) Sincerely, Gene Wirchenko |
|
#2
| |||
| |||
|
You can use this against a SQL SELECT R/O cursor : * * From BostonComputerNewsNetwork @NJ Fox-user 6-22-94 *+ *PURPOSE: * To Make SQL read-only cursor into R/W cursor * Must be real file not filtered view * *SYNTAX: * m.retstat = mkcursrw(m.cn) *PARAMETERS: * m.cn -(C) Cursor alias name to be made read/writable. * *RETURNS: * m.retstat -(L) .t. made the read-only cursor to R/W cursor. * .f. the cursor alias name does not correspend * to a cursor. *REMARKS: *SEE ALSO: *- * FUNCTION mkcursrw PARAMETER m.cn PRIVATE m.cf, m.retstat m.cf = DBF(m.cn) IF ".TMP"=RIGHT(m.cf,4) USE (m.cf) AGAIN IN 0 ALIAS dummycname USE IN (m.cn) USE (m.cf) AGAIN IN 0 ALIAS (m.cn) USE IN dummycname SELECT (m.cn) m.retstat = .t. ELSE m.retstat = .f. ENDIF RETURN m.retstat -- Fred Microsoft Visual FoxPro MVP "Gene Wirchenko" news:02k3a2l0dcllsclbnpopk8jn58mmai9mbt@4ax.com... > I have a R/O cursor that is an extract from a table. I need it > to be R/W so I can run some a what-if scenario on it. I would rather > not create a table since I do not want to keep the data. How can I > create a R/W version of the cursor that I have? > > Failing that, how can I create a R/W extract from a table? (The > original table must not be modified by the subsequent writes.) > > Sincerely, > > Gene Wirchenko > |
|
#3
| |||
| |||
|
Hi Gene, > I have a R/O cursor that is an extract from a table. I need it > to be R/W so I can run some a what-if scenario on it. I would rather > not create a table since I do not want to keep the data. How can I > create a R/W version of the cursor that I have? R/O cursors mostly are hidden filters on the original table. If you add a dummy field to the field list, then Foxpro mostly builds a separate cursor which is writable. Something like SELECT *, "" as dummy FROM ... INTO CURSOR ... should do the trick. Another way: CREATE a new cursor from the structure of your R/O cursor and append the rows from R/O cursor. Regards Bernhard Sander |
|
#4
| |||
| |||
|
[readded comp.databases.xbase.fox] [reordered to chronological] On Wed, 28 Jun 2006 09:29:54 -0400, "Dan" wrote: >"Gene Wirchenko" >news:02k3a2l0dcllsclbnpopk8jn58mmai9mbt@4ax.com... >> I have a R/O cursor that is an extract from a table. I need it >> to be R/W so I can run some a what-if scenario on it. I would rather >> not create a table since I do not want to keep the data. How can I >> create a R/W version of the cursor that I have? >> >> Failing that, how can I create a R/W extract from a table? (The >> original table must not be modified by the subsequent writes.) >This is what I used to do when I used VFP6. > >*--Create cursor >SELECT * FROM Temp INTO CURSOR ReadOnlyCursor > >*--Put structure of cursor into array >AFIELDS(laStruc, "ReadOnlyCursor") > >*--Create new cursor from structure array, new cursor will be read/write >CREATE CURSOR ReadWriteCursor FROM ARRAY laStruc > >*--Append records from read only cursor >APPEND FROM DBF("ReadOnlyCursor") This worked nicely. Thank you. Sincerely, Gene Wirchenko |
|
#5
| |||
| |||
|
[corrected deleted attribution] On Wed, 28 Jun 2006 10:12:03 +0200, Bernhard Sander >[Gene Wirchenko:] >> I have a R/O cursor that is an extract from a table. I need it >> to be R/W so I can run some a what-if scenario on it. I would rather >> not create a table since I do not want to keep the data. How can I >> create a R/W version of the cursor that I have? >R/O cursors mostly are hidden filters on the original table. No. I created the cursor with nofilter. This from the VFP 6 On-line Docs: CURSOR CursorName [NOFILTER], which stores query results in a cursor. If you specify the name of an open table, Visual FoxPro generates an error message. After SELECT is executed, the temporary cursor remains open and is active but is read-only. Once you close this temporary cursor, it is deleted. Cursors may exist as a temporary file on the drive or volume specified by SORTWORK. Why the cursor ends up R/O makes no sense to me, but that is how it is documented and how VFP 6 behaves. >If you add a dummy field to the field list, then Foxpro mostly builds a separate >cursor which is writable. >Something like >SELECT *, "" as dummy FROM ... INTO CURSOR ... >should do the trick. It did not work for me. VFP said that the cursor was R/O. This is an old trick to avoid a filter. >Another way: >CREATE a new cursor from the structure of your R/O cursor and append the rows >from R/O cursor. That did work. Someone posted code for this. Sincerely, Gene Wirchenko |
|
#6
| |||
| |||
|
You can also get a read-write cursor from a read-only cursor like this: Use DBF("read-only-alias") Again Alias RWCursor It's completely undocumented, but it still works in VFP9 (where it's also unnecessary Dan Gene Wirchenko wrote: > [corrected deleted attribution] > > On Wed, 28 Jun 2006 10:12:03 +0200, Bernhard Sander > > >> [Gene Wirchenko:] >>> I have a R/O cursor that is an extract from a table. I need it >>> to be R/W so I can run some a what-if scenario on it. I would >>> rather not create a table since I do not want to keep the data. >>> How can I create a R/W version of the cursor that I have? >> R/O cursors mostly are hidden filters on the original table. > > No. I created the cursor with nofilter. This from the VFP 6 > On-line Docs: > > CURSOR CursorName [NOFILTER], which stores query results in a cursor. > If you specify the name of an open table, Visual FoxPro generates an > error message. After SELECT is executed, the temporary cursor remains > open and is active but is read-only. Once you close this temporary > cursor, it is deleted. Cursors may exist as a temporary file on the > drive or volume specified by SORTWORK. > > Why the cursor ends up R/O makes no sense to me, but that is how > it is documented and how VFP 6 behaves. > >> If you add a dummy field to the field list, then Foxpro mostly >> builds a separate cursor which is writable. >> Something like >> SELECT *, "" as dummy FROM ... INTO CURSOR ... >> should do the trick. > > It did not work for me. VFP said that the cursor was R/O. This > is an old trick to avoid a filter. > >> Another way: >> CREATE a new cursor from the structure of your R/O cursor and append >> the rows from R/O cursor. > > That did work. Someone posted code for this. > > Sincerely, > > Gene Wirchenko |
![]() |
« Previous Thread
|
Next Thread »
| Thread Tools | |
| Display Modes | |
| |
All times are GMT -4. The time now is 12:50 PM.




Linear Mode