SELECT tmp58orders
IF TYPE('stornomark')='U'
ALTER table tmp58orders ADD stornomark c(1)
ENDIF
IF TYPE('typemark')='U'
ALTER table tmp58orders ADD typemark c(1)
ENDIF
REPLACE stornomark WITH 'S' FOR s__storno
REPLACE typemark WITH 'M' FOR s__type<2
REPLACE typemark WITH 'S' FOR s__type=2
tmp58orders is a writable cursor created by SQL SELECT (one output row only) and the error reported was:ASKER
ASKER
Visual FoxPro (VFP), and its predecessor FoxPro, is a data-centric, object-oriented, procedural, database programming language and IDE from Microsoft last released in 2007 that still has some active use due to its low cost of deployment and fairly rapid development. In 2008, Microsoft released a set of add-ons for VFP's xBase components to allow interoperability with various Microsoft technologies. It allows data processing against its native file-based data tables or database servers such as SQL Server.
TRUSTED BY
This is not about a cursor you created by a query, still ALTER TABLE might better only be applied to tables.
Is s__storno a variable? What about s__type? We know VFP reports a missing variable when a field is missing, as it can't judge from a name expression what it is. Since field names are prioritized over variables, VFP looks for variables last and then reports a missing variable, though a field is meant.
Not sure if ALTER TABLE always has the new table as currently selected alias, your REPLACEs depend on that. I always prefer the syntax with IN alias.
How about using other approaches?
1. Make sure the fields exist:
SELECT ..., ' ' as stornomark, ' ' as typemark ....INTO CURSOR tmp58orders
2. Create the fields separate:
Create Cursor curMarks (recno I, stornomark C(1), typemark C(1))
With the second approach you relate the side cursor to the main cursor tmp58orders without an index by record number.
Sample code:
Open in new window
That would even work with multiple records in tmp58orders. Of course the relation is not needed for a single record, but if done, you can even populate a grid with records as if there only was a single cursor, you just have to set the grid recordsource to the side cursor curMarks. You can then display tmp58orders fields as well as curMarks fields using the colums controlsources, as the grid scans through curMarks and the relation will move the record pointer in tmp58orders, also a REPLACE IN curMarks could have tmp58orders fields in it's FOR condition, the relation makes sure the right tmp58orders record is checked for the FOR condition.
Bye, Olaf.