Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Referencing variable cursor names and their fields
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Network:
Windows 2003 Server
Database:
Visual FoxPro
Divers
Thread ID:
01515685
Message ID:
01515743
Vues:
54
>>>>You do need it according to the original logic. (he was doing seek and replace).
>>>
>>>either one works the same for me, so i use the short one, are there any drawbacks of using it my way?
>>>
>>>
>>>CREATE CURSOR cur (pk int autoinc, xvalue char(10), fkPlans int)
>>>CREATE CURSOR pln (pk int autoinc, xvalue char(10))
>>>
>>>INSERT INTO cur (xvalue, fkPlans) VALUES ('', 2)
>>>INSERT INTO cur (xvalue, fkPlans) VALUES ('', 4)
>>>INSERT INTO cur (xvalue, fkPlans) VALUES ('', 6)
>>>INSERT INTO cur (xvalue, fkPlans) VALUES ('', 8)
>>>
>>>INSERT INTO pln (xvalue) VALUES ('ONE')
>>>INSERT INTO pln (xvalue) VALUES ('TWO')
>>>INSERT INTO pln (xvalue) VALUES ('THREE')
>>>INSERT INTO pln (xvalue) VALUES ('FOUR')
>>>INSERT INTO pln (xvalue) VALUES ('FIVE')
>>>INSERT INTO pln (xvalue) VALUES ('SIX')
>>>INSERT INTO pln (xvalue) VALUES ('SEVEN')
>>>
>>>UPDATE cur SET xvalue = pln.xvalue from pln WHERE pln.pk = cur.fkplans
>>>
>>>* or
>>>
>>>UPDATE cur SET xvalue = pln.xvalue FROM pln INNER JOIN cur ON cur.fkPlans = pln.pk
>>>
>>>
>>
>>The first variation is not traditionally written and I'm not sure why it works. May be VFP somehow allows this type of join.
>
>
>This type of join also work in SQL Server :-)
>
>CREATE TABLE #cur (pk int IDENTITY(1,1), xvalue char(10), fkPlans int)
>CREATE TABLE #pln (pk int IDENTITY(1,1), xvalue char(10))
>
>INSERT INTO #cur (xvalue, fkPlans) VALUES ('', 2)
>INSERT INTO #cur (xvalue, fkPlans) VALUES ('', 4)
>INSERT INTO #cur (xvalue, fkPlans) VALUES ('', 6)
>INSERT INTO #cur (xvalue, fkPlans) VALUES ('', 8)
>
>INSERT INTO #pln (xvalue) VALUES ('ONE')
>INSERT INTO #pln (xvalue) VALUES ('TWO')
>INSERT INTO #pln (xvalue) VALUES ('THREE')
>INSERT INTO #pln (xvalue) VALUES ('FOUR')
>INSERT INTO #pln (xvalue) VALUES ('FIVE')
>INSERT INTO #pln (xvalue) VALUES ('SIX')
>INSERT INTO #pln (xvalue) VALUES ('SEVEN')
>
>UPDATE #cur SET xvalue = #pln.xvalue
>       from #pln
>WHERE #pln.pk = #cur.fkplans
>
>SELECT * FROM #cur
>
>DROP TABLE #cur
>DROP TABLE #pln 
>
I think it's the old type of JOIN syntax, but to me personally it's harder to read / understand, than the other variation.
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform