Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SELECT SQL 2 memo fields in one field
Message
 
 
À
14/07/1997 15:51:46
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00039857
Message ID:
00039901
Vues:
36
>>>Is there a way in a SELECT SQL, to have 2 memo fields resulted in one memo field?
>>>
>>>In my table, I have 2 memo fields. Let say MEMO1 and MEMO2. I would like to do something like this in my SQL:
>>>
>>>SELECT MEMO1+MEMO2 FROM mytable...
>>>
>>>But, this gives "String is too long to fit". Any workaround for that?
>>You can try trimming the contents of the memo field to shorten the overall return field's space. Something like:
>>SELECT ALLTRIM(memo1)+ALLTRIM(memo2) FROM mytable...
>>else, you might have to select both fields in your SELECT and combine the info into one variable by code.
>
>I tried the ALLTRIM this morning and it is not working.
>
>The reason I want to have all in one field is to avoid changing one of my main functions.
>
>Thanks.
OK Michel, you've made me actually "think" on this one.
The problem seems to be when you combine data from two memo fields, the corresponding field type returned from SELECT is a character field and NOT a memo field. Character field can only hold 254. So here's what you have to do:

1. Create a cursor with a memo field to hold the data you're going to use for combining the 2 memo fields.
CREATE CURSOR c1 (memo m) You could enter more fields if you like.
2. SELECT memo1, memo2 FROM mytable INTO CURSOR c2
3. Use looping (DO WHILE, SCAN, etc) and issue INSERT INTO c1 (memo) VALUES (c2.memo1+c2.memo2) inside.

Is this too much work for what you're trying to do?
John
It's "my" world. You're just living in it.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform