Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Create cursor from array (with memo)
Message
From
14/05/2001 11:38:12
 
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00506806
Message ID:
00506848
Views:
16
This message has been marked as the solution to the initial question of the thread.
Hi!

Sorry for typos, definitely I rush somewhere today ;)

>Hi!
>
>I cannot help you otehr way than just tell you to scan the entire array to llok if some field should be a memo field. Read below statements accurately and try to understand.
>
>Well, the reason why VFP do not use memo field is because it cannot prdict which fields require character type and which memo field type. Suggest that 100 rows contain empty memo field. 101-th contain memo with 1000 characters. What VFP will do when cursor structure already exists? It does not alter the structure. VFP just use the first array row as atemplate to get the data structure. Than all other rows should contain data that do not conflict with the first row. For example, if in the first row is a character string with a 10 characters, character(10) field will be made. Other rows data will be than truncated to the 10 characters.
>
>When getting data from table into array, all character data appended by spaces to the length of the field, that fixes the problem when just getting data and than writing back. With memo fields this could not be done and that is the main reason why these commands do not work with memo fields.
>
>In your case you require to simulate the process using VFP commands, but with change of the cursor structure each time you find a conflict. This, of course, will work slower. You can also create the structure of the cursor using first row, but this is not a good solution anyway, ecause still need scan array to search for memo data and see which columns require to be memo.
>
>Can you use another approach to data transfer in your application? The array is not that good as you see. And structure of the array is not that hard to get. What is that for? If you explain, I can try to give you better solution.
>
>P.S. If you have a time, you can try to write an error handler for CREATE CURSOR ... FROM ARRAY... command that will catch error (conflict), change the result cursor structure (that will be created at the moment when error handler fired) and use RETRY command to continue. I don;t know if RETRY will work here, however, I guess it worth a try.
>
>P.P.S. ALTER TABLE command works for cursors created using CREATE CURSOR command.
>
>HTH.
>
>>Thanks Vlad!
>>
>>The problem is with the structure of the table, i dont have it, i get the array and need to pass it to a cursor, i guess before doing the loop i will need to do other loop asking for the type() of the position in the array, to know the fields structure in order to say 'create cursor'
>>
>>TIA
>>*------------------------------------------------------------------------
>>Hi!
>>
>>You cannot do this directly with a sinle command. Creating cursor and appending it using APPEND FROM ARRAY command cannot help too because it does not works with memo fields. I guess you require to make a loop with GATHER command:
>>
>>for i = 1 to alen(myArray,1)
>> gather from myArray MEMO
>>endfor
>>
>>This, again requires to create the cursor with base structure.
>>
>>HTH.
>>
>>>Hello!
>>>
>>>Is there any way to create a cursor from array , where one position of the avector is a field with more than 256 characters?
>>>Im tring this:
>>>
>>>DIMENSION myArray(1)
>>>myArray(1) = REPLICATE('p',900)
>>>CREATE CURSOR MyCursor FROM ARRAY myArray
>>>
>>>TIA
Vlad Grynchyshyn, Project Manager, MCP
vgryn@yahoo.com
ICQ #10709245
The professional level of programmer could be determined by level of stupidity of his/her bugs

It is not appropriate to say that question is "foolish". There could be only foolish answers. Everybody passed period of time when knows nothing about something.
Previous
Reply
Map
View

Click here to load this message in the networking platform