Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Already exist in database
Message
From
07/10/2003 09:57:06
 
 
To
07/10/2003 02:48:07
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00835634
Message ID:
00835743
Views:
10
>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.
Previous
Reply
Map
View

Click here to load this message in the networking platform