Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
IIF within Insert command
Message
De
21/11/2021 01:44:46
Lutz Scheffler
Lutz Scheffler Software Ingenieurbüro
Dresden, Allemagne
 
 
À
21/11/2021 01:37:24
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01682738
Message ID:
01682747
Vues:
39
>>>Howdy,
>>>Scanning a table and as I go through the records, want to insert records into another table. One field can be valid in the source table, so I want to update the destination record/field with "No Listing provided", else inset the data with the source field/data.
>>>
>>>Here's is the code:
>>> *Scan Sourcetable
>>> * insert into NewTable (field A, Field B, Field C) values (SourceTable.FieldA, SourceTable.FieldB, iif empty(allt(sourceTable.fieldC)), "No LIsting Provided", allt(sourceTable.fieldC))
>>>
>>>Receiving a syntax error.
>>
>>>Howdy,
>>>Scanning a TABLE AND AS I GO through the RECORDS, want TO INSERT RECORDS INTO another TABLE. One FIELD can be VALID IN the SOURCE TABLE, so I want TO UPDATE the destination RECORD/FIELD WITH "No Listing provided", ELSE inset the DATA WITH the SOURCE FIELD/DATA.
>>>
>>>Here's is the code:
>>> *SCAN Sourcetable
>>> * INSERT INTO NewTable (FIELD a, FIELD B, FIELD C) VALUES (Sourcetable.FieldA, Sourcetable.FieldB, IIF EMPTY(ALLT(Sourcetable.fieldC)), "No LIsting Provided", ALLT(Sourcetable.fieldC))
>>>
>>>Receiving a syntax ERROR.
>>
>>Or, maybe without DBX, just SQL ....
>>
>>INSERT INTO NewTable (;
>> field_A, Field_B, Field_C);
>> SELECT;
>>  Sourcetable.FieldA,;
>>  Sourcetable.FieldB,;
>>  IIF(EMPTY(ALLT(Sourcetable.fieldC)), "No LIsting Provided", ALLT(Sourcetable.fieldC));
>> FROM Sourcetable
>>
>>;)
>
>Instead of Empty(Allt(Sourcetable.fieldC)) you can simply use Empty(Sourcetable.fieldC). As I write very often, Alltrim() is used way too often.

You are right. I just copy-pasted it. :)

ALLTRIM is used to often and on meaningless places. In fact, the statement
..
 IIF(EMPTY(Sourcetable.fieldC), "No LIsting Provided", Sourcetable.fieldC);
..
would do, except Field_C is Varchar. Even then, most likely TRIM() will be enough.
Words are given to man to enable him to conceal his true feelings.
Charles Maurice de Talleyrand-Périgord

Weeks of programming can save you hours of planning.

Off

There is no place like [::1]
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform