Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Cross Tab
Message
 
To
20/01/1999 08:37:24
Senna Dwipayana
Indo Rebel Apparel Cv
Bandung, Indonesia
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Miscellaneous
Thread ID:
00177691
Message ID:
00177966
Views:
42
>As an example :
>Mytable1 crosstabbed to myTable2 and I want to change myTable2 into myTable3 with the same structure with myTable1 (because I changed some content on myTable2) and I think this also what you're trying to explain up there, but can you be more spesific ?
>
Hi Senna,

Here you go. Note, however, that this has not been debugged or tested, but it should work. It assumes the aliases are as you stated, and I've used "field1" to indicate the row values, "field2" for the column values, and "field3" for the value at the intersection. You'll have to modify it slightly, but it should do the job:
* Create the cursor to receive the data
SELECT MyTable1
= AFIELDS(a_fields)
* Note: If the table is not a free table
* modification of the array has to occur
* before the cursor can be created
* This could be used to create a table
CREATE CURSOR MyTable3 FROM ARRAY a_fields
SELECT MyTable2
lcalias = ALIAS()
lnfields = FCOUNT()
SCAN
  m.field1 = EVALUATE(FIELD(1))
  SELECT MyTable3
  FOR lni = 2 TO lnfields
    m.field2 = FIELD(lni, lcalias)
    m.field3 = EVALUATE(FIELD(lni, lclias))
    APPEND BLANK
    * Or individual REPLACE statements
    GATHER MEMVAR
  NEXT
ENDSCAN
hth,
George

Ubi caritas et amor, deus ibi est
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform