Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Already exist in database
Message
De
07/10/2003 09:57:06
 
 
À
07/10/2003 02:48:07
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00835634
Message ID:
00835743
Vues:
12
>i want to use sql to select fields in a table then copy it to a table already included in my project.
>
>so, i'm getting an error "already exist in the database.."
>
>but i still want to use my sql, what should i do?

method 1: Do your select into a cursor, then append to the existing table, if there, or copy to it, if not there. If you want to clean out the target table first, then zap it prior to the append (if you can use it exclusively)
e.g.,
Select field1, field2, ..., field10 From sourceTable Into Cursor cuTmp
Set Database To yourDatabase
If InDBC("targetTable","Table")
  If !Used("targetTable")
    Use targetTable In 0 Exclusive
  EndIf
  Select targetTable
  Zap
  Append From DBF("cuTmp")
Else
  Copy To targetTable Database yourDatabase
EndIf
method 2: Check for the existence of the target table, if there, drop it
e.g.,
Select field1, field2, ..., field10 From sourceTable Into Cursor cuTmp
Set Database To yourDatabase
If InDBC("targetTable","Table")
  If Used("targetTable")
    Use In targetTable
  EndIf
  Drop Table targetTable
EndIf
Copy To targetTable Database yourDatabase
Insanity: Doing the same thing over and over and expecting different results.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform