Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
V6s5 - Make individual slip item details from clubbed de
Message
De
19/09/2003 08:00:21
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00830572
Message ID:
00830611
Vues:
26
>Hi all
>
>I have this type of data entry in the Invoice Line Items
>
>Case  Case  Item   Item
>From  To    ID     Qty.
> 1     1    ABC     5
> 1     1    DEF     5
> 2     3    GHI    45
> 4     4    JKL     3
>
>
>
>I have to create the view in the following manner for printing purposes
>
>Case  Item  Item
>No    ID    Qty.
> 1    ABC    5
> 1    DEF    5
> 2    GHI   45
> 3    GHI   45
> 4    JKL    3
>
>
>Please advise

Bhavbhuti,
IMHO having this as a view is unnecessary. A view is typically an SQL select. Doing it through code would be efficient :
Select From,To, ItemID, ItemQty ;
   From myTable ;
   Order By From,To,ItemID ;
   Into Cursor crsTemp
Create Cursor crsResult (CaseNo i,  ItemID c(3),  ItemQty i)
Local array arrRecs[Floor(65000/3),3]
Local lnRec, ix
lnRec = 0
Select crsTemp
Scan
  For ix=crsTemp.From To crsTemp.To
  	lnRec = lnRec + 1
    arrRecs[lnRec,1] = ix
    arrRecs[lnRec,2] = crsTemp.ItemID
    arrRecs[lnRec,3] = crsTemp.ItemQty
    If lnRec >= floor(65000/3)
    	Insert Into crsResult from array arrRecs
    	lnRec = 0
    endif
  Endfor
EndScan
Dimension arrRecs[lnRec,3]
Insert Into crsResult from array arrRecs
Use In 'crsTemp'
Select crsResult
Brows
Note that array is used to speed up insertion (indiviual inserts would be much slower).
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform