Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
V6s5 - Make individual slip item details from clubbed de
Message
From
19/09/2003 08:00:21
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00830572
Message ID:
00830611
Views:
27
>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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform