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 13:40:57
 
 
À
16/02/2001 12:54:05
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00476591
Message ID:
00476741
Vues:
27
Dragan,

On a similar subject I have been using ALTER TABLE after a SELECT to get rid of columns I don't want. I always wished there was a command like SELECT * EXCEPT Table1.MyField...

Instead of listing each field in the SELECT, I sometimes do
SELECT * FROM orders INNER JOIN ordItems ON orders.order_id=ordItems.order_id INTO CURSOR MyCursor
USE (DBF()) AGAIN IN 0 ALIAS ReadWrite
USE
ALTER TABLE ReadWrite DROP COLUMN order_id_b
ALTER TABLE ReadWrite RENAME COLUMN order_id_a TO order_id
>>>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
>>>
>>>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?
>
>It complained about the table being still open elsewhere - it worked only after I closed the original r/o cursor. Does make sense, that one was read only, and was open in another workarea.
>
>This thing should actually gain us some speed, specially when we had to include dummy fields in a select statements to be placeholders for later additions - we now can do them outside of the SQL statement. What I'm saying is that instead of
>
select ..., space(40) as name, ...
>we can now do the select without this, and add the field afterwards. This should lift some burden off SQL's back.
Daniel
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform