Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
UPDATE instead of REPLACE
Message
De
28/12/2010 13:12:46
 
 
À
28/12/2010 12:22:44
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 XP SP2
Network:
Windows XP
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01493981
Message ID:
01494028
Vues:
72
>Thanks sir for providing following speedy codes
>
>update cr_sum ;
>	set dr_amount = jj.cr_amount - jj.cr_amount1 ;
>	from crsalp ;
>	join ( ;
>	select sum(iif(cr.type = 'P', cr_amount, 000000.00)) as cr_amount, ;
>	sum(iif(cr.type = 'D', cr_amount, 000000.00)) as cr_amount1, ;
>	cr.vou_no ;
>	from crsalp as cr ;
>	group by cr.vou_no ;
>	)  as jj on jj.vou_no = crsalp.vou_no
>
>
>But........
>
>It copy first result to all records in cr_sum
>
>It must update cr_sum.vou_no with crsalp.vou_no
>
>COMPARISON
>
>The codes takes 0.55 seconds and TORE'S following codes takes 8 minutes
>
>
>select crsalp
> goto top
>Scan
>   lnVou_no=crsalp.you_no
>   select ;
>      sum(iif(type="P",cr_amount,0))as cr_amount,;
>      sum(iif(type="D",dr_amount,0))as ddr_amount1;
>      where vou_no=lnvou_no;
>      from crsalp;
>      group by vou_no;
>      into cursor xyz readwrite
>   wait window transform(lnvou_no) at srows()/2,scols()/2 nowait
>   update cr_sum set dr_amount=xyz.cr_amount-xyz.ddr_amount1 where vou_no=lnVou_no
>Endscan
> 
>messagebox("Done",0+16+256,"Successfully")
>
>
>I need more modifications in Charlie Schreiner's codes.
>
>Thanks
update cr_sum ;
set dr_amount = jj.cr_amount - jj.cr_amount1 ;
	from ( select sum(iif(type = 'P', cr_amount, 000000.00)) as cr_amount, ;
	sum(iif(type = 'D', cr_amount, 000000.00)) as cr_amount1, ;
        cr.vou_no ;
	from crsalp ;
	group by vou_no ;
	)  as jj
        where cr_sum.vou_no = jj.vou_no
or ( not exactly equal ! )
update cr_sum ;
set dr_amount = jj.dr_amount ;
	from ( select sum(icase(type = 'P', cr_amount, type = 'D', -cr_amount, 000000.00)) as dr_amount, ;
        cr.vou_no ;
	from crsalp ;
	group by vou_no ;
	)  as jj
        where cr_sum.vou_no = jj.vou_no
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform