>>>Hi,
>>>
>>>I have come across an issue where when I try to macro expand a string (that contains INSERT command) and the string is over 612 characters I get error. If the string is less than 612, macro works.
>>>
>>>Is there a limit? And if there is, if there a way to get around it?
>>>
>>>Thank you in advance for any help.
>>
>>The following quick test works:
>>
>>
>>x = "0"
>>FOR i = 1 TO 500
>> x = x + " + 1"
>>next
>>? &x
>>
>>
>>String length is 2001.
>>
>>I would say, check the syntax. Or some built-in limitation of the corresponding SQL command.
>
>Thank you, Hilmar. The string I create for macro is passed from one function to another. Perhaps this is where I hit the limit.
>
>Thank you, ALL, for your suggestions.
Passing parameters doesn't have a practical limit. The following works without problem:
clear
x = REPLICATE("abc", 100000)
function_a(x)
FUNCTION function_a(tcpar)
? LEN(x)
ENDFUNC
(Length of parameters = 300,000)
In any case, it is worthwhile to try to check each aspect separately, e.g., parameter passing, macro expansion, SQL command.
For example, you can build the entire SQL command - you don't even need macro expansion for this - as a string, and then execute it all at once. For example, if the list of fields is variable:
lcCommand = "select " + lcFieldList + " from MyTable"
&lcCommand
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)