Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL to normalize a denormalized table?
Message
 
À
25/11/1998 00:20:25
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00161242
Message ID:
00161264
Vues:
18
Albert,

It is a challenge and my suggestion is a long shot but we can try can we not?

create a 1 field cursor containing an integer from one to the maximum number of points with a pointcount field. I assume there must be ..., because the pointvalue string must be able to hold only a finite number of values right?

Assuming this value to be nMaxPointCount...
create cursor Crs (Fld N(2,0))
for n= 1 to nMaxPointCount
    m.Fld= n
    insert into crs from memvar
endfor
Now multiply your table with this cursor
select table.*,fld as pointnumber,substr(pointValues,(crs.fld-1)*l+1,crs.fld) as pointvalue,;
    from Table,crs;
    having not empty(pointvalue)
I assume that pointvalues is right padded with blanks, which it is by default.

HTH,




>Is there a way to get from this:
>
>datapoints(timestamp, pointcount, pointvalues)
>
>note - point values is binary data where there are pointcount points packed into a character field (pointvalue x is at character position x*sizeof(pointvalue)).
>
>to:
>
>datapoints(timestamp, pointnumber, pointvalue)
>
>Where there is on record per point for a given timestamp.
>
>The solution must be a single SQL statement and the statement cannot be dynamically generated.

If things have the tendency to go your way, do not worry. It won't last. Jules Renard.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform