Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Xbase equivalent for select sql
Message
De
03/05/2005 21:28:07
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
 
À
03/05/2005 00:00:53
Suhas Hegde
Dental Surgeon
Sirsi, Inde
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 6 SP5
Divers
Thread ID:
01010381
Message ID:
01010654
Vues:
17
>hi,
> can any 1 show me a faster way of doing this in xbase ?
>
>
>create table bhav.dbf free ;
>(symbol c(20),series c(20),open f(20,2),high f(20,2),low f(20,2),close f(20,2),;
>last f(20,2),prevclose f(20,2),tottrdqty f(20,2),tottrdval  f(20,2),timestamp c(20),date d)
>
>index on padr(symbol,20)+padr(series,20)+dtoc(date) tag idxbhav
>
>create table del.dbf free ;
>(settlement I,recordtype I,symbol c(20),series c(20),qtytrd I,delqty I,;
>pdqty f(6,2),date d)
>
>index on padr(symbol,20)+padr(series,20)+dtoc(date) tag idxdel
>
>select a1.date,a1.symbol,a1.series,a1.open,a1.high,a1.low,a1.close,a1.last,;a1.prevclose,a1.tottrdqty,a1.tottrdval,;
>a2.delqty,((a2.delqty*100)/a1.tottrdqty) as delpercent from bhav a1 , del a2 ;
>where padr(a1.symbol,20)+padr(a1.series,20)+dtoc(a1.date) = ;
>padr(a2.symbol,20)+padr(a2.series,20)+dtoc(a2.date) into table bhav_data
>
>
>Tia
>
>Suhashegde

A single SQL command should normally be faster than a complicated loop. It looks quite optimized; if it takes too long, you might see if the JOIN clause is faster than the WHERE (I use JOIN to specify the condition to combine tables; WHERE is still necessary to specify a condition within a single table):
select a1.date,a1.symbol,a1.series,a1.open,a1.high,a1.low,a1.close,a1.last,;a1.prevclose,a1.tottrdqty,a1.tottrdval,;
a2.delqty,((a2.delqty*100)/a1.tottrdqty) as delpercent from bhav a1 join del a2 ;
on padr(a1.symbol,20)+padr(a1.series,20)+dtoc(a1.date) = ;
padr(a2.symbol,20)+padr(a2.series,20)+dtoc(a2.date) into table bhav_data
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform