Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Tip o' the Day: ALTER TABLE on a Cursor
Message
De
16/02/2001 10:51:03
 
 
À
16/02/2001 02:48:50
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00476591
Message ID:
00476645
Vues:
32
Funny that you would be talking about ALTER TABLE on cursors...

It seems that, for whatever reason, when I'm running the code below, if it's running on my NT 4 Server (locally), it can't find the cursor file (i.e. VFP launches the Open dialog) to ALTER. It works fine when I run the application across the network from my Win2000 and Win98 machines, any ideas?


lcSelectFields = ...

SELECT &lcSelectFields FROM reffile ;
INTO CURSOR tcsrRefFile
USE DBF('tcsrRefFile') AGAIN IN 0 ALIAS csrRefFile
USE IN tcsrRefFile
ALTER TABLE csrRefFile ADD COLUMN newfield c(50)
SELECT csrRefFile


I've even tried:

ALTER TABLE DBF('csrRefFile') ADD COLUMN newfield c(50)

but not only does that not fix the problem on NT 4, it causes the problem across the board.

I use cursors all the time in the app, though this is the only time I've needed to add a new field to one...

Oh yeah, VFP 6 SP 4

Thanks,
- Brian


>>>>I just found out this works, with a caveat (at least in VFP5). I used a complex SELECT - SQL to generate a report cursor. I wanted to add a memo column to the resultant cursor:
* Report cursor:
>>>>SELECT ;
>>>>  ... ;
>>>>  INTO CURSOR MyCursor ;
>>>>  ...
>>>>
>>>>* Make the cursor read-write:
>>>>USE ... AGAIN etc.
>>>>
>>>>* Add the memo column:
>>>>ALTER TABLE ... ADD COLUMN MyMemo M
Yes, I know you can use CREATE CURSOR to create a dummy cursor with a single M column, then add that into the JOINs in the SELECT - SQL, but it was a pretty heinous statement already so I thought I'd be lazy ;-)
>>>>
>>>>One caveat I've found that any long cursor column names are truncated to the old FP standard 10 characters (watch out if you have column names that match to that length).
>>>>
>>>>Maybe just of academic interest, but it could be a useful tool in report generation or just general-purpose data munging.
>>>>
>>>>BTW can anyone confirm if this works in VFP6?
>>>
>>>Yep, this still works in VFP6. Now, can someone tell us if it works with VFP7 and just using the READWRITE clause of the SELECT and the ALTER TABLE?
>>
>>Are long cursor column names still clipped in VFP6?
>
>Still clipped at 10 chars. Happens at the ALTER TABLE. It's still long at the USE AGAIN.


VFP6 SP5, VFP8 SP1, VFP 9 SP 1 and Win XP SP 3 (unless otherwise specified)


www.wulfsden.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform