Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Import data from text file
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01242133
Message ID:
01242167
Vues:
26
>Hi Boris,
>pleased to see you again :)
>i was working on xhtml + ajax + asp etc technologies since 1-2 months anyway ....
>
>yes its one file and each time its creating so
>
>first line ( begins with 01 ) means inv. header data
>second and others (begins with 02) means inv.detail data

Create an intermediate cursor with 19 char fields (because I saw that is the maximum fields in the 01 record):
lcFileToImport = GETFILE([001])
IF NOT EMPTY(lcFileToImport) AND;
   JUSTEXT(lcFileToImport) == [001]
   lcCreate = [CREATE CURSOR crsImport (Fld1 C(20)]
   FOR lnFor = 2 TO 19
       lcCreate  = lcCreate + [, Fld]+TRANSFORM(lnFor)+[ C(20)]
   NEXT
   lcCreate  = lcCreate + [)]
   &lcCreate
   SELECT crsImport
   APPEND FROM (lcFileToImport) DELIMITED
   BROWSE NORMAL
   GO TOP
   SCAN
       IF ALLTRIM(Fld1) == [01]
          *** Manage header record
          *** with proper transformation of the types
          *** between C(20) and the real Header table type
       ELSE
          *** Manage detail records
          *** with proper transformation of the types
          *** between C(20) and the real Detail table type
       ENDIF 
   ENDSCAN
   RENAME (lcFileToImport) TO FORCEEXT(lcFileToImport,[TRN])
ENDIF
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform