Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Double data
Message
De
07/01/2019 14:01:08
 
 
À
07/01/2019 09:11:16
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows 10
Network:
Windows Server 2008 R2
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01665171
Message ID:
01665175
Vues:
102
This message has been marked as the solution to the initial question of the thread.
J'aime (1)
>Sir I have this data
>
>
>CREATE CURSOR table1(code c(4),names c(10),debit n(4),credit n(4),code2 c(4))
>INSERT into table1 VALUES ('3201','Apple',100,0,'')
>INSERT into table1 VALUES ('3203','Mango',125,0,'')
>INSERT into table1 VALUES ('3204','Date',200,0,'')
>INSERT into table1 VALUES ('3202','Orange',350,0,'')
>
>
>
>
>
>
>I want insert following rows at the end of table1
>
>
>
>
>Method:
>
>code column will be replace with code2
>Debit column will be replaced with credit
>Credit column will be replaced with debit
>code2 column will be replace with code
>
>But I do not want to use any temporary table or cursor.
>
>Is there any other method to make data double according to method.
>
>Finally I need this data
>
>
>

For adding the rows, consider using INSERT INTO ... SELECT. I assume you have the data for the new code column somewhere (call it NewCodeValue), so you'll want something like:
INSERT INTO table1 (Code, Names, Debit, Credit, Code2) ;
   SELECT NewCodeValue, Names, Credit, Debit, Code ;
      FROM table1
I'll guess that you actually will need a WHERE clause for the SELECT, so you only insert the rows that don't already have matches.

To update the existing records, you'll want something like:
UPDATE table1 ;
   SET code2 = t1.code ;
   FROM table1 t1 ;
   WHERE table1.code = t1.code2
     AND EMPTY(table1.code2)
Tamar
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform