Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Data insert into oracle
Message
 
 
À
27/08/2005 21:09:20
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 7 SP1
OS:
Windows 2000 SP4
Network:
Windows 2000 Server
Database:
Oracle
Divers
Thread ID:
01043861
Message ID:
01044744
Vues:
14
>Thanks Mark for your detailed explaination, i really appreciate it.
>
>Reg the different table name , its all the same, i wanted to paste a sample table but i ended up pasting from my source code.
>
>This is a migration of old legacy data to the new oracle database . That's why i had begin trans inside the loop.But i could use your logic to not to insert if one table fails.
>
>Thanks for the tip on Tableupdate.
>
>"There is a better way to do this whithout inserting into a view then updating that view"
>Could you tell me what is that..

Since you are working with legacy data that I am assuming is in VFP tables, I would create the INSERT syntax ONE time per VFP table parameterizing the fields in the VALUES clause, then SCANning the VFP table:
USE MyVfpTable IN 0
SELECT MyVfpTable
lnKount = afields(laFields)
lcInsert = [INSERT INTO MyOracleTable (PKFieldName, Field2Name, ..., FieldXName) VALUES (?lnNewID,]
for lnI = 1 to lnKount
    if laFields[lnI, 1] == [PKFIELDNAME]
       loop
    endif
    if inlist(laFields[lnI, 2), [C], [V], [M])  && trim any character type data (V is varchar in VFP9)
       lcInsert = lcInsert + [?RTRIM(MyVfpTable.] + laFields[lnI, 1] + [)]
    else
       lcInsert = lcInsert + [?MyVfpTable.] + laFields[lnI, 1]
    endif
    if lnI < lnKount
       lnInsert = lcInsert + [,]
    endif
endfor
SCAN
   SQLEXEC(lnHandle, [get sequencename.nextval as newid from dual], [crsNewID])
   lnNewID = crsNewID.NewID
   lnSuccess = SQLEXEC(lnHandle, lcInsert)
   if lnSuccess < 0
      *** handle error here
   endif
ENDSCAN
If you do not care about what the NewID is for child table records, then take it out of the lcInsert above and out of the SCAN loop.
Mark McCasland
Midlothian, TX USA
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform